Created
November 25, 2020 23:29
-
-
Save readyready15728/0fa8fd4bc4f41bbcd1151d266f009520 to your computer and use it in GitHub Desktop.
I had a dream about this and had to make it
This file contains hidden or 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
class Integer | |
@@memo = {0 => 1} | |
def factorial | |
return @@memo[self] if @@memo.include? self | |
value = self * (self - 1).factorial | |
@@memo[self] = value | |
value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment