Skip to content

Instantly share code, notes, and snippets.

@itsthomson
Created April 30, 2009 04:18
Show Gist options
  • Save itsthomson/104256 to your computer and use it in GitHub Desktop.
Save itsthomson/104256 to your computer and use it in GitHub Desktop.
def fib(n) #sum in ruby
return n if (0..1).include? n
fib(n-1) + fib(n-2) if n > 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment