M = P[r(1+r)^n/((1+r)^n)-1)]
M= total monthly mortgage payment
P= principal loan amount
r= your monthly interest rate. Mortgage lenders will typically give you an annual rate. You’ll need to divide that figure by 12 (the number of months in a year) to get the monthly rate. If your interest rate is 3%, your monthly rate would be 0.0025 (0.03/12=0.0025).
n= number of payments over the loan’s lifetime. Multiply the number of years in your loan term by 12 (the number of months in a year) to get the number of total payments for your loan. For example, a 30-year fixed mortgage would have 360 payments (30x12=360).