Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = 320000
- annualInterestRate = 0.2
- low = balance / 12.0
- high = balance
- guess = (high + low) / 2.0
- while True:
- tempBal = balance
- for month in range(1, 13):
- tempBal -= guess # remove guess from the unpaid balance
- tempBal += (annualInterestRate/12.0) * tempBal # calculate the monthly interest and add the monthly interest to the balance
- if tempBal <= 0:
- break
- else:
- if guess < tempBal:
- low = guess
- else:
- high = guess
- guess = (high + low) / 2.0
- print('Lowest Payment: ', round(guess))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement