Skip to content

Instantly share code, notes, and snippets.

@edymerchk
Created August 7, 2014 14:44
Show Gist options
  • Save edymerchk/bec53278286bead6654f to your computer and use it in GitHub Desktop.
Save edymerchk/bec53278286bead6654f to your computer and use it in GitHub Desktop.
Memoization
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