OverView:
In this article i would like to publish a article on Strong Numbers from 1 to N Numbers
Description:
A Number is strong number if sum of the factorial of its digits equal to number itself.
Example:
145=1!+4!=5!
Program:
Public Static void Main(String[] args)
{
In this article i would like to publish a article on Strong Numbers from 1 to N Numbers
Description:
A Number is strong number if sum of the factorial of its digits equal to number itself.
Example:
145=1!+4!=5!
Program:
Public Static void Main(String[] args)
{
int
num,i,f,r,sum=0,num1;
clrscr();
Console.WriteLine("Enter a Number");
num=Convert.ToInt32(Console.ReadLine());
num1=num;
while
(num){
i=1,f=1;
r=num%10;
while
(i<=r){
f=f*i;
i++;
}
sum=sum+f;
num=num/10;
}
if
(sum==num1)
Console.WriteLine("{0} is a Strong Number",num1);
else
Console.WriteLine("{0} is Not a Strong Number",num1);
}
No comments:
Post a Comment