Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C-program to check a number is KRISHNAMURTHY number or not



In this C-program we will check the number is Krishnamurthy number(i.e: krishnamurthy number is a number which is equal to the sum of the factorials of it's digits, example:145=1!+4!+5!) or not. The number will be taken from the user.color>

input:

The number(i.e : 567,610,7899 etc.)

output:

The number will be Krishnamurthy or not

CODE---->


#include
#include
color> void main()color>
{
int i,n,a,r,c=0,s;
clrscr();
printf("Please,Enter a number:color>");
scanf("%dcolor>",&n);
a=n;
while(n>0color>)
{
r=n%10;;
s=1;
for(i=rcolor>;i>=1color>;i--color>)
{
s=s*i;
}
c=c+s;
n=n/10;
}
if(c==acolor>)
printf("\n%d is a Krishnamurthy number.color>",a);
else
printf("\n%d is not a Krishnamurthy number.color>",a);
getch();
}



Don't just read, write it, run it.....color>

RESULT:color>








This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

C-program to check a number is KRISHNAMURTHY number or not

×

Subscribe to Programjoy.blogspot.com

Get updates delivered right to your inbox!

Thank you for your subscription

×