Skip to content

Instantly share code, notes, and snippets.

@iizukanao
Created July 25, 2011 05:11
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 iizukanao/1103592 to your computer and use it in GitHub Desktop.
Save iizukanao/1103592 to your computer and use it in GitHub Desktop.
fibonacci
fib = (n) ->
throw new Error "n must be positive integer" if n < 0
switch n
when 0 then 0
when 1 then 1
else
fib(n-1) + fib(n-2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment