#include<stdio.h>
//function to calculate factorial
int fact(int i)
{
int k=1;
if(i==1)
{
return 1;
}
else
{
k=i*fact(i-1);
}
return k;
}
void main()
{
int n,m,sum=0,a;
int i;
printf("Enter a no");
scanf("%d",&n);
m=n;
while(n>0)
{
a=n%10;
sum=sum+fact(a);
n=n/10;
}
if(m==sum)
{
printf("No is strong no");
}
else
{
printf("Not a strong no");
}
}
output
Enter a no 32
Not a strong no
//function to calculate factorial
int fact(int i)
{
int k=1;
if(i==1)
{
return 1;
}
else
{
k=i*fact(i-1);
}
return k;
}
void main()
{
int n,m,sum=0,a;
int i;
printf("Enter a no");
scanf("%d",&n);
m=n;
while(n>0)
{
a=n%10;
sum=sum+fact(a);
n=n/10;
}
if(m==sum)
{
printf("No is strong no");
}
else
{
printf("Not a strong no");
}
}
output
Enter a no 32
Not a strong no
No comments:
Post a Comment