Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = 320000
- annualInterestRate = 0.2
- monthlyInterestRate = (annualInterestRate)/12
- lowerBound = balance/12
- upperBound = (balance*(1+monthlyInterestRate)**12)/12
- payment = (upperBound + lowerBound)/2
- newBalance = balance
- epsilon = 0.01
- while abs(upperBound-lowerBound) > .01:
- for month in range(1, 13):
- balance = (balance - payment)*(1 + monthlyInterestRate)
- if (balance) > 0.01:
- lowerBound = payment
- balance = newBalance
- payment = (upperBound + lowerBound)/2.0
- else:
- upperBound = payment
- balance = newBalance
- payment = (upperBound + lowerBound)/2.0
- print 'Lowest Payment: ' + str(round(payment,2))
Add Comment
Please, Sign In to add comment