Guest User

Untitled

a guest
Jan 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. balance = 320000
  2. annualInterestRate = 0.2
  3.  
  4. _balance = balance
  5. interest = 0.0
  6. lower = balance/12
  7. upper = (balance*(1+annualInterestRate/12)**12)/12
  8. payment = round((lower+upper)/2,2)
  9. while True:
  10.     balance = _balance
  11.     mes = 1
  12.     while mes < 13:
  13.         interest = (balance - payment)*(annualInterestRate/12)
  14.         balance = balance - payment + interest
  15.         mes += 1
  16.     if (upper-lower) <= 0.1:
  17.         break
  18.     elif balance > 0:
  19.         lower = payment
  20.         payment = round((payment+upper)/2,2)
  21.     else:
  22.         upper = payment
  23.         payment = round((payment+lower)/2,2)
  24. print('Lowest Payment: ' + str(round(payment,2)) )
Add Comment
Please, Sign In to add comment