Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ssokolowskisebastian/287f417c5a420ce461503bb1b50ee3d3 to your computer and use it in GitHub Desktop.
Save ssokolowskisebastian/287f417c5a420ce461503bb1b50ee3d3 to your computer and use it in GitHub Desktop.
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