Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit488f143

Browse files
RamanaMendapre-commit-ci[bot]MaximSmolskiy
authored
Performance: 25% faster Project Euler 73#10503 (#11553)
* Seperate slow_solution and solution* Add performance benchmark* [pre-commit.ci] auto fixes from pre-commit.com hooksfor more information, seehttps://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>
1 parent5c50572 commit488f143

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎project_euler/problem_073/sol1.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ def solution(max_d: int = 12_000) -> int:
3636

3737
fractions_number=0
3838
fordinrange(max_d+1):
39-
forninrange(d//3+1, (d+1)//2):
39+
n_start=d//3+1
40+
n_step=1
41+
ifd%2==0:
42+
n_start+=1-n_start%2
43+
n_step=2
44+
forninrange(n_start, (d+1)//2,n_step):
4045
ifgcd(n,d)==1:
4146
fractions_number+=1
4247
returnfractions_number

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp