Fun Factorials

For any positive integer n , we define n ! as the factorial of n . Some numbers are equal to the sum of the factorials of their digits. For example 40585=4+0+5+8+5.

Find such a number with three digits.


The answer is 145.

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.

2 solutions

David Holcer
Mar 21, 2015
1
2
3
4
5
from math import *
for i in range(10**2,10**3):
    i=str(i)
    if factorial(int(i[0]))+factorial(int(i[1]))+factorial(int(i[2]))==int(i):
        print i

Lachlan Kuhr
Jan 19, 2015

It can be observed that for any integer over 6! the number produced will be greater than three digits. The starting digit can be limited to between the integers one and six as the three digit number cannot begin with a one.

Starting with the first digit as one it can be seen that 6! can be eliminated from the choices available as it surpasses the required sum of between 100 and 199. This leaves the choice from the digits between zero and five. Arbitrarily choosing the next two digits as five and four respectively, will lead to a sum of: 154=1!+5!+4!=145

It can be then observed that a simple swap between the order of the digits 5 and 4 will result in a number supports these conditions.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...