// The sum of the factorial of each digit is equal to the number itself
#include <iostream.h>
#include <conio.h>
void main()
{
int a , j,sum = 0, dig, fact = 1;
cout<<"\n Enter a No.?";
cin>>a;
for(int i = a; i>0; i = i /10)
{
dig = i%10;
fact = 1;
j = 1;
while(j<=dig)
{
fact = fact * j;
j++;
}
sum = sum + fact;
}
if(sum == a)
cout<<"\n Krishna Murti No.";
else
cout<<"\n Not a Krishna Murti No.";
getch();
}
JAVA One =
ReplyDeleteimport java.io.*;
public class Krishnamurti
{
public static void main(String args[])Throws IOException
{
Buffer Reader br=new Buffer Reader (new Input Stream Reade(System.in)
System.out.println("Enter A Number");
int a=Integer.parsInt(br.readLine());
int st1;
int a1=a;
while(a!=0)
{
st1=a%10;
a=a/10;
int st2=1;
for(int i=1;i>=st1;i++)
}
}
if(st2==a1)
System.out.println("Your number is Krishnamurti");
elce
System.out.println("Your number is not Krishnamurti");
}
}
(if you have any questione email me at duttaapd2009@gmail.com)
Gr8
ReplyDelete