Skip to content

Instantly share code, notes, and snippets.

@micseydel
Created September 11, 2016 21:16
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 micseydel/1cb177a948fa6907aa747530bbad3602 to your computer and use it in GitHub Desktop.
Save micseydel/1cb177a948fa6907aa747530bbad3602 to your computer and use it in GitHub Desktop.
MONTHLY_INVESTMENT = 188.0
MONTHS_TO_INVEST = 120
YEARLY_INTEREST = 0.04
MONTHLY_INTEREST = (1 + YEARLY_INTEREST)**(1.0/12) - 1
def main():
balance = 0
for month in xrange(MONTHS_TO_INVEST):
balance *= 1 + MONTHLY_INTEREST
balance += MONTHLY_INVESTMENT
print balance
principal = MONTHLY_INVESTMENT * MONTHS_TO_INVEST
interest = balance - principal
print principal, interest
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment