Skip to content

Instantly share code, notes, and snippets.

@liyaodong
Last active August 29, 2015 14:12
Show Gist options
  • Save liyaodong/caa2c1ac6e706f81cb00 to your computer and use it in GitHub Desktop.
Save liyaodong/caa2c1ac6e706f81cb00 to your computer and use it in GitHub Desktop.
「Geek每日一题」2014.12.30
@Zkuns
Copy link

Zkuns commented Dec 30, 2014

def count (n, sum=0, adult=1, born=[0, 0, 0])
  return sum if n < 0
  count(n - 1, sum + adult, adult + born[0], [born[1], born[2], adult])
end
puts count(100)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment