-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ24.c
43 lines (36 loc) · 865 Bytes
/
Q24.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
43
//C program to print all Strong Numbers between 1 to n
//C program to print all Strong Numbers between 1 to n
#include<stdio.h>
int main()
{
int fact=1,sum=0;
int n,r;
printf("Enter the 'n' number :");
scanf("%d",&n);
printf("\n Strong numbers are :");
for(int i=1;i<=n;i++)
{
int k=i;
while(k!=0)
{
r=k%10;
fact=factorial(r);
k=k/10;
sum=sum+fact;
}
if(sum==i){
printf("%d ",i);
}
sum=0;
}
return 0;
}
int factorial(int f)
{
int mul=1;
for(int i=1; i<=f;i++)
{
mul=mul*i;
}
return mul;
}