Check whether the given number is Strong Number or not.
void main() {
int temp;
int number;
int sum = 0;
printf("Enter number: ");
scanf("%d", &number);
temp = number;
while(temp != 0) {
int digit;
int factorial = 1;
digit = temp % 10;
if(digit == 0 || digit == 1)
factorial = 1;
else {
while(digit != 0) {
factorial *= digit;
digit -= 1;
}
}
sum += factorial;
temp /= 10;
}
if(sum == number) {
printf("%d is strong number\n", number);
}
else {
printf("%d is not strong number\n", number);
}
}
0 Comments