![]() |
Formulae to solve problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Formulae to solve problem (/thread-11152.html) |
Formulae to solve problem - BigDisAok - Jun-25-2018 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 RE: Formulae to solve problem - nilamo - Jun-25-2018 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))) RE: Formulae to solve problem - BigDisAok - Jun-26-2018 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! RE: Formulae to solve problem - nilamo - Jun-26-2018 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 |