Computer Science, asked by tabu732, 1 year ago

What is strong no And also program in simple class

Answers

Answered by Harshittiwari2004
0
A number is called strong number if sum of the factorial of its digit is equal to number itself. For example: 145 since
1! + 4! + 5! = 1 + 24 + 120 = 145

C Program to check a number is strong number or not.C

#include<stdio.h>
int main(){
int num,i,fact,r,sum=0,temp;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while(num){
i=1,fact=1;
r=num%10;
while(i<=r){
fact=fact*i;
i++;
}
sum=sum+fact;
num=num/10;
}
if(sum==temp)
printf("%d is a strong number",temp);
else
printf("%d is not a strong number",temp);

return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
int main(){
int num,i,fact,r,sum=0,temp;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while(num){
i=1,fact=1;
r=num%10;
while(i<=r){
fact=fact*i;
i++;
}
sum=sum+fact;
num=num/10;
}
if(sum==temp)
printf("%d is a strong number",temp);
else
printf("%d is not a strong number",temp);

return 0;
}


Sample Input
Enter a number: 145
Sample Output
145 is a strong number
Sample Input
Enter a number: 234
Sample Output
234 is not a strong number
Similar questions