Skip to content

Instantly share code, notes, and snippets.

@mcdonaldd
Created June 17, 2012 23:26
Show Gist options
  • Save mcdonaldd/2946041 to your computer and use it in GitHub Desktop.
Save mcdonaldd/2946041 to your computer and use it in GitHub Desktop.
Ruby_Intro
class Integer
def fibonacci
if self == 0
0
elsif self < 0
:invalid
elsif self == 1
1
else
(self - 1).fibonacci + (self - 2).fibonacci
end
end
end
puts fibonacci.100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment