Check whether a number is a Strong number or not with C
#include <stdio.h>
int main()
{
int i, original, num, lastDigit, sum;
long fact;
printf("Enter any number to check Strong number: ");
scanf("%d", &num);
original = num;
sum = 0;
while (num > 0)
{
lastDigit = num % 10;
fact = 1;
for (i = 1; i <= lastDigit; i++)
{
fact = fact * i;
}
sum = sum + fact;
num = num / 10;
}
if (sum == original)
{
printf("%d is STRONG NUMBER", original);
}
else
{
printf("%d is NOT STRONG NUMBER", original);
}
return 0;
}
output
Enter any number to check Strong number : 50
50 is NOT STRONG NUMBER
0 Comments