Python Forum

Full Version: Formulae to solve problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

So yesterday some kind people on this forum helped me solve this problem:

Problem PART A : How much of my mortgage is left after X months of repayment. In this case, amount borrowed - 200000, Interest rate 0.03 per anum, time: 72 months, paying back 750 a month.

Part B) Is there a formulae I can use to figure out how many months will it take to complete repayment if I am paying back at 750 a month (I solved it by brute force.)

Part C) How much would I have to repay each month to pay the mortgage back in 20 years (240months). Is there a formulae I can use?

Answer to A:
def mortgage(borrowed, repayment, interest, time):
    print(f"total left after {time} months \n")
    for month in range(months):
      borrowed -= repayment
      borrowed *= (1 + interest / 12)
    print(borrowed)
For answer B I added:

print (month,borrowed)            
        if borrowed <=0 :
            print (month, borrowed)
            break
https://en.wikipedia.org/wiki/Mortgage_calculator

# the interest, monthly, in 0.0NN format.  for 3%:
monthly_interest = 3 / 100 / 12
principal = 200_000
payments = 72 * 12
monthly_payment = (monthly_interest * principal) / (1 - ((1 + monthly_interest) ** (-1 * payments)))
Thanks very much for the equation. It works!!
And thanks for the link, although I still don't understand it. Time to find some videos on cyclotomic polynomials!
I'm sorry, but I can't explain the equation. Math isn't a strong point of mine :p
I can do just enough to get a computer to do the hard math for me lol