Created
September 11, 2016 21:16
-
-
Save micseydel/1cb177a948fa6907aa747530bbad3602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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