Skip to content

Commit beda6fc

Browse files
committed
feat(euler): Optimize problem 034 with a lower upper bound
1 parent 3cea941 commit beda6fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

project_euler/problem_034/sol1.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def solution() -> int:
3030
>>> solution()
3131
40730
3232
"""
33-
limit = 7 * factorial(9) + 1
33+
# The upper bound is 1,499,999, as shown in this proof:
34+
# https://math.stackexchange.com/a/112383/89462
35+
limit = 1_499_999
3436
return sum(i for i in range(3, limit) if sum_of_digit_factorial(i) == i)
3537

3638

0 commit comments

Comments
 (0)