What sum of fact...?

If a a is natural number such that it equals the sum of the factorials of its decimal digits. Find sum of all such a a in base 10.


The answer is 40733.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Adwait Sharma
Jan 31, 2015

include<stdio.h>

include<conio.h>

int main()

{

int n=1,x,y=0,p,m,z;

while(n<10000000) /*  7*9!<9999999  */
{

x=n;

p=0;

z=0;

while(x>0)

{

    p=x%10;

    m=1;

    while(p>0)

    {

        m=m*p;

        p--;

    }

    z=z+m;

    x=x/10;

}

if(z==n)

{

    y=y+n;

}

n++;

}

printf("The Answer is %d",y);

getch();

}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...