Skip to content

Instantly share code, notes, and snippets.

@jessieay
Created June 14, 2012 03:47
Show Gist options
  • Save jessieay/2927897 to your computer and use it in GitHub Desktop.
Save jessieay/2927897 to your computer and use it in GitHub Desktop.
I am learning recursion
class Fixnum
def factorial
if self < 0
raise "You can't take the factorial of a negative number."
elsif
self == 0
1
else
self * (self-1).factorial
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment