Skip to content

Instantly share code, notes, and snippets.

@kazu-yamamoto
Created July 22, 2012 06:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu-yamamoto/3158648 to your computer and use it in GitHub Desktop.
Save kazu-yamamoto/3158648 to your computer and use it in GitHub Desktop.
Fast fib
fib :: Int -> Integer
fib n = fib' n 0 1
where
fib' 0 x _ = x
fib' m x y = fib' (m - 1) y (x + y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment