2017-07-13 03:09:15 +03:00
|
|
|
/**
|
|
|
|
* Modified on 07/12/2017, Kyler Smith
|
|
|
|
*
|
|
|
|
* A number is called strong number if sum of the
|
|
|
|
* factorial of its digit is equal to number itself.
|
|
|
|
*/
|
|
|
|
|
2016-09-19 13:04:20 +03:00
|
|
|
#include<stdio.h>
|
2017-07-13 03:09:15 +03:00
|
|
|
|
|
|
|
|
2016-09-19 13:04:20 +03:00
|
|
|
void strng(int a)
|
|
|
|
{
|
|
|
|
int j=a;
|
|
|
|
int sum=0;
|
|
|
|
int b,i,fact=1;
|
|
|
|
while(a>0)
|
|
|
|
{
|
|
|
|
fact=1;
|
|
|
|
b=a%10;
|
|
|
|
for(i=1;i<=b;i++)
|
|
|
|
{
|
|
|
|
fact=fact*i;
|
|
|
|
}
|
|
|
|
a=a/10;
|
|
|
|
sum=sum+fact;
|
|
|
|
}
|
|
|
|
if(sum==j)
|
|
|
|
printf("%d is a strong number",j);
|
|
|
|
else
|
|
|
|
printf("%d is not a strong number",j);
|
|
|
|
}
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
printf("Enter the number to check");
|
|
|
|
scanf("%d",&a);
|
|
|
|
strng(a);
|
|
|
|
}
|