Guest User

Untitled

a guest
Jan 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. balance = 320000
  2. annualInterestRate = 0.2
  3. monthlyInterestRate = (annualInterestRate)/12
  4. lowerBound = balance/12
  5. upperBound = (balance*(1+monthlyInterestRate)**12)/12
  6. payment = (upperBound + lowerBound)/2
  7. newBalance = balance
  8.  
  9. while abs(newBalance) > 0.01:
  10.  
  11.  
  12. for month in range(1, 13):
  13. newBalance = (balance - payment) * (1 + monthlyInterestRate)
  14.  
  15. if newBalance > 0:
  16. upperBound = payment
  17.  
  18.  
  19. elif newBalance < 0:
  20. lowerBound = payment
  21.  
  22. else:
  23. break
  24. payment = (upperBound + lowerBound)/2
  25. newBalance = balance
  26.  
  27.  
  28. print 'Lowest Payment: ', round((payment), 2)
Add Comment
Please, Sign In to add comment