From beda6fc69abc2bd22ccf53d39ab01e3c8e3a0499 Mon Sep 17 00:00:00 2001 From: ArnabTechiee Date: Thu, 16 Oct 2025 17:20:46 +0530 Subject: [PATCH 1/2] feat(euler): Optimize problem 034 with a lower upper bound --- project_euler/problem_034/sol1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/project_euler/problem_034/sol1.py b/project_euler/problem_034/sol1.py index 8d8432dbbb7a..2d9c879866d1 100644 --- a/project_euler/problem_034/sol1.py +++ b/project_euler/problem_034/sol1.py @@ -30,7 +30,9 @@ def solution() -> int: >>> solution() 40730 """ - limit = 7 * factorial(9) + 1 + # The upper bound is 1,499,999, as shown in this proof: + # https://math.stackexchange.com/a/112383/89462 + limit = 1_499_999 return sum(i for i in range(3, limit) if sum_of_digit_factorial(i) == i) From 9c25148aff9aff6da4bae105da04ae1c28dcadf7 Mon Sep 17 00:00:00 2001 From: ArnabTechiee Date: Sat, 18 Oct 2025 10:25:46 +0530 Subject: [PATCH 2/2] fix: Update proof link to a stable Rosetta Code source --- project_euler/problem_034/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_034/sol1.py b/project_euler/problem_034/sol1.py index 2d9c879866d1..4c3cfe6ccb5c 100644 --- a/project_euler/problem_034/sol1.py +++ b/project_euler/problem_034/sol1.py @@ -31,7 +31,7 @@ def solution() -> int: 40730 """ # The upper bound is 1,499,999, as shown in this proof: - # https://math.stackexchange.com/a/112383/89462 + # https://rosettacode.org/wiki/Talk:Factorions limit = 1_499_999 return sum(i for i in range(3, limit) if sum_of_digit_factorial(i) == i)