You are viewing a single comment's thread. Return to all comments →
memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1)
mymod :: Integer -> Integer mymod x = mod x ((10^8) + 7)
atoi :: String -> Int atoi = read
main = interact $ unlines . map (show. mymod) . map memoized_fib . map atoi . tail .lines
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci
You are viewing a single comment's thread. Return to all comments →
memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1)
mymod :: Integer -> Integer mymod x = mod x ((10^8) + 7)
atoi :: String -> Int atoi = read
main = interact $ unlines . map (show. mymod) . map memoized_fib . map atoi . tail .lines