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.75 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. epsilon = 0.01
  9.  
  10. while abs(upperBound-lowerBound) > .01:
  11. for month in range(1, 13):
  12.  
  13.  
  14. balance = (balance - payment)*(1 + monthlyInterestRate)
  15.  
  16. if (balance) > 0.01:
  17. lowerBound = payment
  18. balance = newBalance
  19. payment = (upperBound + lowerBound)/2.0
  20. else:
  21. upperBound = payment
  22. balance = newBalance
  23. payment = (upperBound + lowerBound)/2.0
  24.  
  25.  
  26. print 'Lowest Payment: ' + str(round(payment,2))
Add Comment
Please, Sign In to add comment