Taddeus Kroes 13 lat temu
rodzic
commit
d8321647bf
1 zmienionych plików z 18 dodań i 0 usunięć
  1. 18 0
      problem34.py

+ 18 - 0
problem34.py

@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+from itertools import combinations
+from math import factorial
+
+def digits(n):
+    return map(int, str(n))
+
+def facsum(n):
+    return sum(facs[d] for d in digits(n))
+
+facs = map(factorial, range(10))
+s = 0
+
+for n in xrange(10, 99999):
+    if n == facsum(n):
+        s += n
+
+print s