Program -
public class Strong{public static int fact(int x)
{
int f = 1;
for(int i = x; i>1; i--)
{
f = f*i;
}
return f;
}
public static void main(String []args){
int n = 145;
int copy = n,temp,strong = 0;
while(n>0)
{
temp = n%10;
strong = strong + fact(temp);
n = n/10;
}
if(copy == strong)
System.out.println("Yes");
else
System.out.println("No");
}
}
No comments:
Post a Comment