The sum of the factorial of its digit is equal to the number itself is called strong number.
for example 145
1! = 1
4! = 24
5! =120
sum = 145
Question:- write a program to check either a user input is a strong number or not.
flowchart
Program
#include <stdio.h>
#include <conio.h>
void main()
{
int num, loop, re, sum = 0, temp, fact;
printf("enter a value of num: ");
scanf("%d", &num);
temp = num;
while (num > 0)
{
loop = 1, fact = 1;
re = num % 10;
while (loop <= re)
{
fact = fact * loop;
loop++;
}
sum = sum + fact;
num = num / 10;
}
if (temp == sum)
{
printf("%d is strong number", temp);
}
else
{
printf("%d is not a strong number", temp);
}
getch();
}
OUTPUT
Enter a value of num: 145
145 is a strong number
Enter a value of num: 123
123 is not a strong number
0 Comments