Skip to content

Instantly share code, notes, and snippets.

@mercutio22
Created October 25, 2012 01:35
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 mercutio22/3949982 to your computer and use it in GitHub Desktop.
Save mercutio22/3949982 to your computer and use it in GitHub Desktop.
Last quiz from a day in the life of an application http://class.stanford.edu/networking/Fall2012/videos/day_app
def T(n):
....: #base case
....: if n == 1:
....: return 1000
....: else:
....: return 1000 + T(n-1)*2
....:
In [32]: T(1)
Out[32]: 1000
In [33]: T(2)
Out[33]: 3000
In [34]: T(3)
Out[34]: 7000
In [35]: T(4)
Out[35]: 15000
In [36]: people=100000
In [37]: n=1
In [38]: while people>0:
....: people -= T(n)
....: n += 1
....:
In [39]: n
Out[39]: 7
In [40]: 100000/7000
Out[40]: 14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment