Skip to content

Instantly share code, notes, and snippets.

@readyready15728
Created November 25, 2020 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save readyready15728/0fa8fd4bc4f41bbcd1151d266f009520 to your computer and use it in GitHub Desktop.
Save readyready15728/0fa8fd4bc4f41bbcd1151d266f009520 to your computer and use it in GitHub Desktop.
I had a dream about this and had to make it
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