Skip to content

Instantly share code, notes, and snippets.

@MiSawa
Created November 16, 2012 16:46
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 MiSawa/4088861 to your computer and use it in GitHub Desktop.
Save MiSawa/4088861 to your computer and use it in GitHub Desktop.
p Hash.new{|hash, n|
hash[n] = n.zero? ? 1 : n < 0 ? 0 : (1..4).map{|i|hash[n-i]}.inject(&:+)
}[50]
#=> 100808458960497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment