Write a C Program to check whether the given number is Strong Number or not?
A number is called Strong Number if sum of the factorial of its digit is equal to number itself.
ie 145
A number is called Strong Number if sum of the factorial of its digit is equal to number itself.
ie 145
1! + 4! + 5! => 1 + 24 + 120 => 145
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,f,r,sum,temp;
int min,max;
printf("Enter minimum range: ");
scanf("%d",&min);
printf("Enter maximum range: ");
scanf("%d",&max);
printf("Strong numbers in given range are: ");
for(num=min; num <= max; num++){
temp = num;
sum=0;
while(temp)
{
i=1;
f=1;
r=temp%10;
while(i<=r)
{
f=f*i;
i++;
}
sum=sum+f;
temp=temp/10;
}
if(sum==num)
printf("%d ",num);
}
getch();
}
output:
Enter minimum range: 100
Enter maximum range: 1000
Strong numbers in given range are: 145
Enter minimum range: 100
Enter maximum range: 1000
Strong numbers in given range are: 145