http://projecteuler.net/index.php?section=problems&id=139

{--
X^2+(X+d)^2 = (dY)^2
-> (2X+d)^2-(2d^2)Y^2= -d^2
-> x^2-2y^2 = -1
where X = d*(x-1)/2, Y = y
perimeter is X+(X+d)+Y = d(x+y)
--}
next (x,y) = (3*x+4*y,2*x+3*y)
main = print.sum.takeWhile (>). map d.iterate next $ (7,5)
where d (x,y) = div (10^8) (x+y)

最近はペル方程式関係が多いなあ。