int fact(int x)
{
int sum=0;
int k=1;
if(x==0)
{
k=1;
}
while(x>=1)
{
k=k*x;
x--;
}
sum=sum+k;
return sum;
}
main()
{
int y;
int out=0;
int ans=0;
int n=3;
while(n<=200000)
{
y=n;
while(y!=0)
{
ans+=fact(y%10);
y/=10;
}
if(ans==n){
printf("\n%d\n",ans);
out+=n;}
ans=0;
n++;
}
printf("sum=%d",out);
}
{
int sum=0;
int k=1;
if(x==0)
{
k=1;
}
while(x>=1)
{
k=k*x;
x--;
}
sum=sum+k;
return sum;
}
main()
{
int y;
int out=0;
int ans=0;
int n=3;
while(n<=200000)
{
y=n;
while(y!=0)
{
ans+=fact(y%10);
y/=10;
}
if(ans==n){
printf("\n%d\n",ans);
out+=n;}
ans=0;
n++;
}
printf("sum=%d",out);
}
No comments:
Post a Comment