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 notCODE---->
#include
#include
{
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();
}
color>