Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
Created November 28, 2008 22:49
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 jbgutierrez/30122 to your computer and use it in GitHub Desktop.
Save jbgutierrez/30122 to your computer and use it in GitHub Desktop.
Smart definition of Fibonacci Sequence (http://tinyurl.com/dst6f)
def fib n
case n
when 0..1 then n
else fib(n-1) + fib(n-2)
end
end
# thouth it should be rewritten as a loop to avoid a stackoverflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment