Created
August 7, 2014 14:44
-
-
Save edymerchk/bec53278286bead6654f to your computer and use it in GitHub Desktop.
Memoization
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
fibbonacci = Hash.new do |accumulator, index| | |
accumulator[index] = fibbonacci[index - 2] + fibbonacci[index - 1] | |
end.update(0 => 0, 1 => 1) | |
irb(main)> fibbonacci[100] | |
=> 354224848179261915075 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment