Skip to content

Instantly share code, notes, and snippets.

@mpwoz
Created June 18, 2014 15:56
Show Gist options
  • Save mpwoz/581486b72b7a32a35aa8 to your computer and use it in GitHub Desktop.
Save mpwoz/581486b72b7a32a35aa8 to your computer and use it in GitHub Desktop.
INTEREST_RATE = [5, 7]
ANNUAL_SAVINGS = [40, 50, 60]
YEARS = [10, 15, 20]
def calculate_total(interest, savings, years):
interest = 1. + interest / 100.
return sum([savings * (interest ** i) for i in range(years)])
for interest in INTEREST_RATE:
for savings in ANNUAL_SAVINGS:
for years in YEARS:
total = calculate_total(interest, savings, years)
total = int(total)
print "{1}k for {2} years at {0}%: {3}k".format(interest, savings, years, total)
print ""
print "-"*25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment