SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top