Question: how to work out how much mortgage?
Answer: M = the total monthly mortgage payment.
P = the principal loan amount.
r = your monthly interest rate. Lenders provide you an annual rate so you'll need to divide that figure by 12 (the number of months in a year) to get the monthly rate. ... 
n = number of payments over the loan's lifetime.