#include<stdio.h>
#include<conio.h>
void main()
{
int temp,n,fact,num,sum=0,i;
clrscr();
printf("Enter the Number: ");
scanf("%d",&num);
temp=num;
sum=0;
while(temp>0)
{
n=temp%10;
fact=1;
for(i=1;i<=n;i++)
fact=fact*i;
sum=sum+fact;
temp=temp/10;
}
if(sum==num)
printf("\nKrishnamurthy's Number :");
else
printf("\n Not a Krishnanurthy's Number ");
getch();
}
good effort ......
ReplyDeletebut it would have been nice from your part if could have mentioned what a krishnamurthy number is before you wrote your code...
Any way a krishnamurthy number is one in which sum of the factorial of the digits of that number gives you the same number .for exambple 145=1!+4!+5!
there are some mistakes in the program.....
ReplyDeleteyou have not declared n in int which you used in for loop statement
for(i=1;i<=n;i++)