Created
May 6, 2025 15:40
-
-
Save ssokolowskisebastian/287f417c5a420ce461503bb1b50ee3d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
start_time = time.time() | |
def gcd(a, b): | |
while b: | |
a, b = b, a % b | |
return a | |
def solution(limit): | |
count = 0 | |
for d in range(2, limit+1): | |
for n in range(d//3, d//2 + 1): | |
if gcd(n, d) == 1 and 1/3 < n/d < 1/2: | |
count += 1 | |
return count | |
print(solution(12000)) | |
print("--- %s seconds ---" % (time.time() - start_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment