* Seperate slow_solution and solution * Add performance benchmark * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix issues * Update sol1.py * Update sol1.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
committed by
GitHub
parent
5c50572476
commit
488f143b8c
@@ -36,7 +36,12 @@ def solution(max_d: int = 12_000) -> int:
|
||||
|
||||
fractions_number = 0
|
||||
for d in range(max_d + 1):
|
||||
for n in range(d // 3 + 1, (d + 1) // 2):
|
||||
n_start = d // 3 + 1
|
||||
n_step = 1
|
||||
if d % 2 == 0:
|
||||
n_start += 1 - n_start % 2
|
||||
n_step = 2
|
||||
for n in range(n_start, (d + 1) // 2, n_step):
|
||||
if gcd(n, d) == 1:
|
||||
fractions_number += 1
|
||||
return fractions_number
|
||||
|
||||
Reference in New Issue
Block a user