Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = 999999
- annualInterestRate = 0.18
- startbalance = balance
- monthlyinterest = annualInterestRate/12
- lower = balance/12
- upper = (balance*((1+monthlyinterest)**12/12))
- balance = startbalance
- minpayment = (upper+lower)/2.0
- while True:
- for a in range(12):
- balance = balance - minpayment
- balance = balance + balance * monthlyinterest
- #balance = (balance - minpayment) * ( 1 + monthlyinterest)
- print "month: " + str(a) + " balance: " + str(balance)
- if abs(balance)<0.08:
- break;
- if balance <0:
- upper = minpayment
- print "upper minpayment has changed to: " + str(minpayment)
- else:
- lower = minpayment
- print "lower minpayment has changed to: " + str(minpayment)
- minpayment = (lower+upper)/2.0
- balance = startbalance
- #ans = payYear(startbalance, balance, monthlyinterest)
- print "minpayment is: " + str(round(minpayment, 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement