Skip to content

Instantly share code, notes, and snippets.

@sirupsen
Last active February 26, 2018 14:28
Show Gist options
  • Save sirupsen/2164021 to your computer and use it in GitHub Desktop.
Save sirupsen/2164021 to your computer and use it in GitHub Desktop.
An extremely simple dynamic programming fibonacci implementation in Ruby using hashes.
# fibonacci
h = Hash.new { |hash,key| hash[key] = hash[key-1] + hash[key-2] }
h[1] = 0
h[2] = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment