Problem 197

197 Investigating the behaviour of a recursively defined sequence
Problem 197 - Project Euler
どうせ循環するのだろうと思い,はじめの1000項をgnuplotでプロット.

実はすぐに,収束していた.
収束のしかたが単純.

f :: Double -> Double
f x = let a = 30.403243784
          y = a - x^2
      in 1E-9 * fromIntegral (floor $ 2 ** y)

p197 :: Double
p197 = loop.iterate f $ (-1)
    where loop (a:b:c:ds) | a == c    = a+b
                          | otherwise = loop $ c:ds

--main = putStrLn.unlines.map show.take 1000 $ us