Skip to content

Instantly share code, notes, and snippets.

@christianesperar
Created March 2, 2014 14:41
Show Gist options
  • Save christianesperar/9307547 to your computer and use it in GitHub Desktop.
Save christianesperar/9307547 to your computer and use it in GitHub Desktop.
Ruby Factorial Method
class Integer
def factorial
result = 0
self.downto(1) { |number| result == 0 ? result = number : result *= number }
return result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment