Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formulae to solve problem
#1
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
Reply
#2
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)))
Reply
#3
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!
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can someone help me solve this programming problem? SuchUmami 6 887 Nov-20-2023, 10:01 AM
Last Post: EdwardMatthew
  A simple problem, how best to solve it? SuchUmami 2 717 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,222 Jun-14-2022, 08:35 PM
Last Post: thesquid
  How do I solve the second problem? Cranberry 1 1,121 May-16-2022, 11:56 AM
Last Post: Larz60+
  Try to solve GTG multiplication table problem. Frankduc 6 1,986 Jan-18-2022, 08:26 PM
Last Post: Frankduc
  Sudoku Solver, please help to solve a problem. AdithyaR 5 2,101 Oct-28-2021, 03:15 PM
Last Post: deanhystad
  General list size question to solve problem Milfredo 3 2,348 Sep-27-2020, 08:42 AM
Last Post: Milfredo
  I want to solve the following problem srisrinu 4 5,930 May-09-2020, 01:07 PM
Last Post: Larz60+
  Solve Pynput Problem when changing language? ppel123 0 2,272 Feb-19-2020, 03:38 PM
Last Post: ppel123
  Hakkerank problem I can't solve ayo 1 2,090 Aug-29-2019, 11:18 AM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020