Project Euler #91: Right triangles with integer coordinates

  • + 0 comments

    For a detailed explanation check out Project Euler 91

    import math
    N = int(input())
    t = sum(min(x*m//y, m*(N - y)//x)
            for x in range(1, N+1)
            for y in range(1, N)
            for m in [math.gcd(x, y)])
    print(2*t + 3*N*N)