Skip to content

Instantly share code, notes, and snippets.

@croach
Created January 16, 2010 01:06
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 croach/278565 to your computer and use it in GitHub Desktop.
Save croach/278565 to your computer and use it in GitHub Desktop.
def fib(n)
if n == 0 || n == 1
n
else
fib(n - 1) + fib(n - 2)
end
end
if $0 == __FILE__
36.times do |i|
puts "n = #{i} => #{fib(i)}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment