project-euler/138_special_isosceles_trian...

21 lines
368 B
Python

#!/usr/bin/env python3
def sols(n):
"""yields int solutions of a**2 - 5 b**2 = 1"""
a, b = 9, 4
for i in range(n):
yield a, b
a, b = 9*a + 20*b, 4*a + 9*b
N = 12
Ls = []
for a, b in sols(N // 2):
a0, b0 = 5*b - 2*a, a - 2*b
m0, n0 = 2*b0 + a0, b0
m, n = 2*b + a, b
Ls += [m0**2 + n0**2, m**2 + n**2]
print(sum(Ls))