Problem Euler #34
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 time from math import factorial as f ts = time.time() def fact_sum(n): res = 0 for d in str(n): res += f(int(d)) return res == n print sum([d for d in xrange(3, 100000) if fact_sum(d)]) print time.time() - ts