Project Euler Problem 057
import Control.Arrow import Data.Array import Data.Ratio -- メモ化 n :: Integer n = 1000 nth_ :: Array Integer (Ratio Integer) nth_ = a where a = listArray (1,n) ((3%2): [nth i | i <- [2..n] ]) nth m = 1 + ((denominator (a!(m-1))) % (denominator (a!(m-1)) + numerator (a!(m-1)))) ans1 :: Int ans1 = length $ filter (uncurry(>).((length . show . numerator)&&&(length . show . denominator))) $ take 1000 $ elems nth_ --153 main :: IO () main = print ans1