/* Prgram to generate strong numbers. */
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,r,s=0,f=1,j=0,p;
clrscr();
printf("Enter the number: ");
scanf("%d",&n);
for(p=1;p<=n;p++)
{
s=0;
for(i=p;i>0;i=i/10)
{
r=i%10;
f=1;
for(j=r;j>0;j--)
{
f=f*j;
}
s=s+f;
}
if(s==p)
printf(" %d ",p);
}
getch();
}
Explanation: A strong no. (n) is a number which is obtained by the sum of factorial of all digit of that no.(n) and equal to the original no.(n). Eg. 145=1!+4!+5!=145 or 1=1!
No comments:
Post a Comment