diff --git a/solutions/034/digitfactorials.py b/solutions/034/digitfactorials.py new file mode 100644 index 0000000..27aa186 --- /dev/null +++ b/solutions/034/digitfactorials.py @@ -0,0 +1,18 @@ +factorials = list(range(10)) +factorials[0] = 1 +for i in range(1, 10): + factorials[i] = factorials[i - 1] * i + +def sum_factorials(n): + sum = 0 + for i in list(str(n)): + sum += factorials[int(i)] + return sum + +sum_all_factorials = 0 + +for i in range(10,10000000): + if i == sum_factorials(i): + sum_all_factorials += i + +print(sum_all_factorials) \ No newline at end of file