project-euler/091_right_triangles_with_in...

19 lines
311 B
Python

#!/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))