Skip to content

Instantly share code, notes, and snippets.

@Twisol
Created December 17, 2010 08:33
Show Gist options
  • Save Twisol/744664 to your computer and use it in GitHub Desktop.
Save Twisol/744664 to your computer and use it in GitHub Desktop.
fib' :: (Integral a) => a -> (a, a)
fib' 0 = (0, 0)
fib' 1 = (0, 1)
fib' x = (b, a + b)
where (a, b) = fib'(x-1)
fib :: (Integral a) => a -> a
fib x = result
where (_, result) = fib'(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment