You are viewing a single comment's thread. Return to all comments →
If you just gave up with Haskell, here is my solution. But, I think my solution is not really great.
fib :: Integer -> Integer fib n = fibz n [0, 0, 1] where fibz :: Integer -> [Integer] -> Integer fibz 0 (_:y:_) = y fibz n (x:y:z:(_)) = fibz (n - 1) [y, z, y + z] main :: IO () main = do n <- readLn :: IO Int l <- fmap (take n . lines) getContents :: IO [String] let x = map read l :: [Integer] output x output :: [Integer] -> IO () output [] = return () output (x:xs) = print ((fib x) `mod` 100000007) >> output xs
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Fibonacci
You are viewing a single comment's thread. Return to all comments →
Haskell Solution
If you just gave up with Haskell, here is my solution. But, I think my solution is not really great.