Skip to content

Instantly share code, notes, and snippets.

@justinvoss
Created November 23, 2011 17:11
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 justinvoss/1389243 to your computer and use it in GitHub Desktop.
Save justinvoss/1389243 to your computer and use it in GitHub Desktop.
Tennis Ball Pyramid
def pyramid(level):
if level == 1:
return 1
return (level * level) + pyramid(level-1)
assert pyramid(1) == 1
assert pyramid(2) == 5
assert pyramid(3) == 14
print "Tennis balls in a 33-level pyramid: %d" % pyramid(33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment