-
Notifications
You must be signed in to change notification settings - Fork 368
/
Copy pathStrong_Number.c
42 lines (40 loc) · 1 KB
/
Strong_Number.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*Name : Hardik Goyal
Github username : HardikGoyal2003
Repositary name : Algorithms
*/
/*What is a strong number?
A strong number is a positive integer whose sum of factorials of its digits equals the number itself. In other words, if we take the
digits of a number and calculate the factorial of each digit, then sum those factorials, and the result is the same as the original number,
then that number is called a strong number.
Problem Statement : To Check Given number is Strong Number or not.
EXAMPLE :
1)
Input: 145
Output: "It is a Strong Number"
*/
#include<stdio.h>
int main(){
int n,factorial=1,sum=0;
printf("Enter Number");
scanf("%d",&n);
int new=n;
while (n>0)
{
int rem = n%10;
n/=10;
for (int i=1; i <=rem; i++)
{
factorial*=i;
}
sum+=factorial;
factorial=1;
}
if (new==sum)
{
printf("It is Strong Number");
}
else
{
printf("It is not a Strong Number");
}
}