Skip to content

Instantly share code, notes, and snippets.

@hechien
Created May 12, 2011 01:50
Show Gist options
  • Save hechien/967790 to your computer and use it in GitHub Desktop.
Save hechien/967790 to your computer and use it in GitHub Desktop.
[Ruby] factorial; 數學階乘
=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