Skip to content

Instantly share code, notes, and snippets.

@jacob414
Created December 3, 2019 15:05
Show Gist options
  • Save jacob414/503110ac59f19bf1306911f21fab52f0 to your computer and use it in GitHub Desktop.
Save jacob414/503110ac59f19bf1306911f21fab52f0 to your computer and use it in GitHub Desktop.
Simplest possible(?), but still readable program that shows how a small percentage increase always leads to doubling.
"""An extremely simple program that shows how a comparately small
percentage of growth turns into a consecutive doubling of the starting
value.
The strength of the relation between energy and
"""
import time
year = 1
money = 1
original_money = 1
growth = 7
while growth > 1:
while True:
print(
"After year {} of {} % growth we have a nominal sum of {} 'currency'."
.format(year, growth, money))
money = round(money + (growth / 100), 2)
year = year + 1
time.sleep(0.5) # ..so that it doesn't print faster than you can see.
if money >= original_money * 2:
print()
print()
print(
"At {} % growth the nominal size of the economy doubled after "
"{} year(s)".format(growth, year))
print(
"-------------------------------------------------------------------------------"
)
print()
print()
money = 1
growth = growth - 1
year = 1
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment