Files
contests/34/main.py

31 lines
587 B
Python

'''
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: As 1! = 1 and 2! = 2 are not sums they are not included.
'''
import math
def listify(i):
return [int(x) for x in str(i)]
def check(i):
l = [math.factorial(x) for x in listify(i)]
return i == sum(l)
def main():
print("This is Patrick")
res = 0
for i in range(1000000):
if check(i):
res += i
print(i)
print(res - 3)
if __name__ == "__main__":
main()