Programming Examples
Java program to Input an integer and check whether it is a special number or not.
WAP to Input an integer and check whether it is a special number or not.
A special number is such a number whose sum of the factorials of each digit is the number itself. For example, 145 is a special number because 1! + 4! + 5! = 1 + 24 +120 = 145. Special numbers are also called factorion.
Solution
class SpecialNumber
{
public static void main(String arr[])
{
int i,j,r,d;
for(i=100;i<=999;i++)
{
r=0;
for(j=i;j>0;j=j/10)
{
d=j%10;
r=r*10+d;
}
if(r==i)
System.out.println(i);
}
}
}
Output