Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. balance = 320000
  2. annualInterestRate = 0.2
  3.  
  4. low = balance / 12.0
  5. high = balance
  6. guess = (high + low) / 2.0
  7.  
  8. while True:
  9.     tempBal = balance
  10.     for month in range(1, 13):
  11.         tempBal -= guess  # remove guess from the unpaid balance
  12.         tempBal += (annualInterestRate/12.0) * tempBal  # calculate the monthly interest and add the monthly interest to the balance
  13.  
  14.     if tempBal <= 0:
  15.         break
  16.     else:
  17.         if guess < tempBal:
  18.             low = guess
  19.         else:
  20.             high = guess
  21.         guess = (high + low) / 2.0
  22.  
  23. print('Lowest Payment: ', round(guess))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement