project-euler/091_right_triangles_with_in...

19 lines
311 B
Python
Raw Normal View History

2023-03-26 22:59:33 +02:00
#!/usr/bin/env python3
from math import gcd
def main(n):
c = 3 * n**2
for x in range(1, n+1):
for y in range(1, n+1):
g = gcd(x, y)
a, b = x//g, y//g
c += min((n-x)//b, y//a) * 2
return c
#print(main(2))
print(main(50))
#print(main(500))