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

また、pell equation.

next (x,y) = (2*x+3*y,2*y+x)
tolength x | (x+2) `mod` 3 ==  = let a = (x+2) `div` 3 in 6*a-2
| (x-2) `mod` 3 ==  = let a = (x-2) `div` 3 in 6*a+2
p094 = takeWhile(<10^9) . map (tolength.fst).tail.iterate next $ (2,1)