Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions project_euler/problem_135/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def solution(limit: int = 1000000) -> int:
frequency = [0] * limit
for first_term in range(1, limit):
for n in range(first_term, limit, first_term):
common_difference = first_term + n / first_term
# n is generated as a multiple of first_term, so keep this path
# entirely integral instead of creating a float for every pair.
common_difference = first_term + n // first_term
if common_difference % 4: # d must be divisible by 4
continue
else:
common_difference /= 4
common_difference //= 4
if (
first_term > common_difference
and first_term < 4 * common_difference
Expand Down