Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = 320000
- annualInterestRate = 0.2
- monthlyInterestRate = annualInterestRate/12
- newbalance = balance
- epsilon = 0.01
- low = 0
- high = balance
- ans = (high + low)/2.0
- while abs(high - low) > epsilon:
- newbalance = balance
- for n in range(12):
- unpaid = newbalance - ans
- newbalance = unpaid + (unpaid * monthlyInterestRate)
- if newbalance > 0:
- low = ans
- else:
- high = ans
- ans = (high + low)/2.0
- print("Lowest payment: " + str(round(ans, 2)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement