Last active
September 22, 2016 13:08
-
-
Save Zoha131/4eac11178c7634cb57f3b67ffdaea488 to your computer and use it in GitHub Desktop.
MIT- 6.00.1x || week 2 || pset-2 || problem-3
This file contains 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
annualInterestRate = 0.2 | |
balance = 320000 | |
# variable for Monthly Interest rate | |
mir = annualInterestRate / 12.0 | |
pb = balance | |
#lower bound | |
lwb = balance /12 | |
#upper bound | |
upb = (balance*((1+mir)**12))/12.0 | |
#middle bound | |
mmp = (lwb+upb)/2 | |
# test function | |
def test(): | |
# minimum monthly payment | |
global mmp | |
mmp = (lwb+upb)/2 | |
global pb | |
pb = balance | |
for n in range(12): | |
# monthly unpaid balance | |
mup = pb - mmp | |
pb = mup + (mup * mir) | |
while True: | |
if pb <= 0 and abs(pb) < mmp: | |
break | |
elif pb < mmp: | |
lwb = mmp | |
test() | |
elif pb > mmp: | |
upb = mmp | |
test() | |
print("Lowest Payment: " + str(round(mmp, 2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment