Skip to content

perf: keep Euler 135 arithmetic integral - #14990

Open
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/optimize-euler-135-8594
Open

perf: keep Euler 135 arithmetic integral#14990
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/optimize-euler-135-8594

Conversation

@tomatotomata

Copy link
Copy Markdown

project_euler/problem_135/sol1.py already generates n as a multiple of first_term, but the inner loop converted that exact relationship to floating point on every iteration. This patch keeps the calculation integral with // for both the quotient and the division by four.

The solution and its existing doctests are unchanged in behavior. The full default calculation still returns 4989.

Checks:

  • python -m doctest -v project_euler/problem_135/sol1.py
  • python -m ruff check project_euler/problem_135/sol1.py
  • python -c "... solution() ..." -> 4989
  • git diff --check

Fixes #8594

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize Project Euler solutions

1 participant