What is strong number?
When the sum of the factorial of a number’s individual digits are equal to the number itself, then that number is called a strong number.
Example: 145 since 1! + 4! + 5! = 1 + 24 + 120 = 145.
C program to find strong number:
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 44 45 46 47 48 49 50 51 |
#include<stdio.h> int main() { int num,i,fact,r,sum=0,temp; printf("Please enter a number to find strong 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("\nThe number %d is a strong number",temp); else printf("\nThe number %d is not a strong number",temp); return 0; } |