-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path034.py
More file actions
35 lines (24 loc) · 717 Bytes
/
034.py
File metadata and controls
35 lines (24 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Completed
"""
Problem 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.
Answer: 60803ea798a0c0dfb7f36397d8d4d772
"""
from common import check
from math import factorial
PROBLEM_NUMBER = 34
ANSWER_HASH = "60803ea798a0c0dfb7f36397d8d4d772"
result = 0
for n in range(10, 100000):
total = 0
n_str = str(n)
for c_str in n_str:
c = int(c_str)
total += factorial(c)
if total == n:
result += n
check(result, PROBLEM_NUMBER, ANSWER_HASH)