Created
May 12, 2011 01:50
-
-
Save hechien/967790 to your computer and use it in GitHub Desktop.
[Ruby] factorial; 數學階乘
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
(1..10).each{|i| | |
puts i.! | |
} | |
=end | |
class Integer | |
def ! | |
_return_val = 1 | |
self.times{|_current| | |
_return_val *= (_current + 1) | |
} | |
return _return_val | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment