Skip to content

Instantly share code, notes, and snippets.

@mizukmb
Created June 9, 2017 08:23
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 mizukmb/b35bafe77267d970489b96d8479800ad to your computer and use it in GitHub Desktop.
Save mizukmb/b35bafe77267d970489b96d8479800ad to your computer and use it in GitHub Desktop.
fib :: Int -> Int
-- Pattern match
-- fib 0 = 0
-- fib 1 = 1
--
-- fib n = fib (n-1) + fib (n-2)
-- Guard
fib n
| n == 0 = 0
| n == 1 = 1
| otherwise = fib (n-1) + fib (n-2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment