[ create a new paste ] login | about

Link: http://codepad.org/cp7gIFKu    [ raw code | output | fork ]

Python, pasted on Oct 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
balance = 10000
annualInterestRate = .18
monthlyInterestRate = annualInterestRate/12
low = balance/12
high = (balance * ((1 + monthlyInterestRate))**12)/12
mid = (low + high)/2
epsilon = 0.01
newb = balance

while (high-low) >= epsilon:
    newb = balance
    mid = (low + high)/2
    for month in range (1,13):
        newb = (newb - mid) * (1 + monthlyInterestRate)
    if newb <= epsilon:
        high = mid
    else:
        low = mid
print('Lowest Payment: ') + str(round (mid,2))


Output:
1
Lowest Payment: 903.26


Create a new paste based on this one


Comments: