Here you will get program for strong number in C.
What is Strong Number?
A number in which the sum of factorial of individual digits is equal to the number is called strong number.
For example, 145 is a strong number because 145=(!1)+(!4)+(!5)=1+24+120=145
The below C program will check whether a given number in strong number or not.
Program for Strong Number in C
#include<stdio.h> int fact(int n){ int i,fac=1; for(i=1;i<=n;++i){ fac*=i; } return fac; } int main(){ int n,t,sum,m; printf("Enter a number:"); scanf("%d",&n); m=n; while(m!=0){ t=m%10; sum+=fact(t); m=m/10; } if(sum==n){ printf("Strong Number"); } else{ printf("Not Strong Number"); } return 0; }
Output
Comment below if you are facing any difficulty to understand above strong number in C program.
The post Strong Number in C appeared first on The Crazy Programmer.