Program to check given number is Strong number or not

#include<stdio.h>
int fac(int k);
int main( )
{
    int n, j, i, num=0, sum=0;
    
    printf("Enter a number");
    scanf("%d",&n);

    j=n;


    while(n>0)

     {
         i=n%10;
         n=n/10;
         sum=fac(i);
         num=num+sum;
     }

if(num==j)

   printf("%d is strong number",j);

else

   printf("%d is not strong number",j);

return 0;

}

int fac(int k)

{
    if(k==0 || k==1)
        return 1;
    else
      return(k*fac(k-1));
}

   

Post a Comment

0 Comments