Skip to content

Instantly share code, notes, and snippets.

@nskeip
Created June 13, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nskeip/0cc6a77ae707e8baa481bf8c60d9003d to your computer and use it in GitHub Desktop.
Save nskeip/0cc6a77ae707e8baa481bf8c60d9003d to your computer and use it in GitHub Desktop.
fibonacci :: Integer -> Integer
fibonacci 0 = 0
fibonacci 1 = 1
fibonacci n = fibohelper n 1 0
fibohelper 1 acc1 acc2 = acc1
fibohelper c acc1 acc2 = fibohelper (c - 1) (acc1 + acc2) acc1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment