C Program to check strong numbers...
//example for strong number..145! is strong number i.e 1!*4!*5!=1*24*120=145!
#include<stdio.h>
int fact(int n)
{
if(n==0)
return 1;
else
return n*fact(n-1);
}
void main()
{
printf("enter number:");
scanf("%d",&n);
while(n>0)
{
dig=n%10;
n=n/10;
sum=sum+fact(n);
}
if(sum==n)
printf("%d is strong number",n);
else
printf("%d is not strong number",n);
}
#include<stdio.h>
int fact(int n)
{
if(n==0)
return 1;
else
return n*fact(n-1);
}
void main()
{
printf("enter number:");
scanf("%d",&n);
while(n>0)
{
dig=n%10;
n=n/10;
sum=sum+fact(n);
}
if(sum==n)
printf("%d is strong number",n);
else
printf("%d is not strong number",n);
}
Comments
Post a Comment