我的代码:
balance = 320000
annualInterestRate = 0.2
originalBalance = balance
month = 1
monthly_interest = annualInterestRate / 12
low = originalBalance/12
high = (originalBalance*(1 + monthly_interest)**12)/12
epsilon = 0.01
min_payment = (high + low)/2.0
while min_payment*12 - originalBalance > epsilon:
while month < 13:
balance = (originalBalance - min_payment)/10 * (1+ monthly_interest)
if balance <= 0.00:
low = min_payment
min_payment = (high + low)/2.0
elif balance > 0.00:
high = min_payment
min_payment = (high + low)/2.0
month += 1
print "Lowest payment: " + str(round(min_payment, 2))
但是,我得到 26666.0,而我实际上应该得到 29157.09。我究竟做错了什么?