Here's Exactly How Much You'll Pay Your Mortgage Company Over 10, 15, Or 30 Years - When comparing a 15-year mortgage versus a 30-year mortgage, it helps to figure out how much you'll pay in total over time.

Buying a house is one of the largest purchases many people will make over the course of their lives. And a mortgage will be one of the biggest loans a person will take out.

Monthly mortgage payments are generally calculated using a formula that combines the principal (the amount of money borrowed in the loan), the annual interest rate for the loan (what the lender charges you to borrow that money), and the term of the loan (the number of years it will take to pay the mortgage off).

The formula works backward from the idea that each month, a borrower will be charged interest on the remaining balance of the loan, and then that balance will be reduced by the amount of the monthly payment. For a standard fixed-rate, fixed-term mortgage, we know how many payments the borrower will be making, and so we can figure out exactly how much they need to pay each month so the remaining balance of the loan is zero at the end of the term.

Using that basic mortgage payment formula, we can come up with some estimates for how much you'll end up actually paying your mortgage provider over time, based on some of the key parameters of the loan.

A bonus just for you: Click here to claim 30 days of access to Business Insider PRIME

The term of a loan is a huge factor in how much a borrower will pay in total. Shorter-term loans will have a higher monthly payment, but because there is less time for interest to compound, borrowers on a shorter-term loan will end up paying much less interest overall.

Indeed, author Chris Hogan suggested in his book "Everyday Millionaires: How Ordinary People Built Extraordinary Wealth — and How You Can Too" that long-term mortgages are a big reason why many people don't become rich.

Interest rates also make a big difference in how much a borrower will pay back in total. Higher rates will lead to higher monthly payments and more total interest paid on the loan.

Let's assume that a borrower is taking out a $250,000 loan under the following three term and rate scenarios:

A 30-year term and a 4.25% annual interest rate, which at the time of writing is listed as the mortgage purchase rate offered by Wells Fargo.

A shorter 15-year term and a 4.25% interest rate.

A 30-year term, but a higher 5% interest rate.

Using the standard mortgage payment calculation, the two 30-year mortgages will have a lower monthly payment than the shorter-term 15-year mortgage:

Read more: The most and least expensive places to live in America

But that higher monthly payment means accruing less interest over time and paying off the principal of the loan faster. Here's what the three different scenarios would have paid off over the first 10 years of the mortgage:

After 10 years, the 15-year mortgage would have a much lower outstanding principal balance than the 30-year loans, and the slightly higher interest rate would result in a higher outstanding balance for the 30-year loan at 5% interest:

The effect of mortgage terms and interest rates can be seen in the total amount paid back to the bank at the end of the 15- or 30-year term. The shorter-term leads to much less interest being paid overall, and the slightly higher 5% rate eventually leads to about $40,000 more in interest over a 30-year term:

Buying a house is one of the largest purchases many people will make over the course of their lives. And a mortgage will be one of the biggest loans a person will take out.

Monthly mortgage payments are generally calculated using a formula that combines the principal (the amount of money borrowed in the loan), the annual interest rate for the loan (what the lender charges you to borrow that money), and the term of the loan (the number of years it will take to pay the mortgage off).

The formula works backward from the idea that each month, a borrower will be charged interest on the remaining balance of the loan, and then that balance will be reduced by the amount of the monthly payment. For a standard fixed-rate, fixed-term mortgage, we know how many payments the borrower will be making, and so we can figure out exactly how much they need to pay each month so the remaining balance of the loan is zero at the end of the term.

Using that basic mortgage payment formula, we can come up with some estimates for how much you'll end up actually paying your mortgage provider over time, based on some of the key parameters of the loan.

A bonus just for you: Click here to claim 30 days of access to Business Insider PRIME

The term of a loan is a huge factor in how much a borrower will pay in total. Shorter-term loans will have a higher monthly payment, but because there is less time for interest to compound, borrowers on a shorter-term loan will end up paying much less interest overall.

Indeed, author Chris Hogan suggested in his book "Everyday Millionaires: How Ordinary People Built Extraordinary Wealth — and How You Can Too" that long-term mortgages are a big reason why many people don't become rich.

Interest rates also make a big difference in how much a borrower will pay back in total. Higher rates will lead to higher monthly payments and more total interest paid on the loan.

Let's assume that a borrower is taking out a $250,000 loan under the following three term and rate scenarios:

A 30-year term and a 4.25% annual interest rate, which at the time of writing is listed as the mortgage purchase rate offered by Wells Fargo.

A shorter 15-year term and a 4.25% interest rate.

A 30-year term, but a higher 5% interest rate.

Using the standard mortgage payment calculation, the two 30-year mortgages will have a lower monthly payment than the shorter-term 15-year mortgage:

Read more: The most and least expensive places to live in America

But that higher monthly payment means accruing less interest over time and paying off the principal of the loan faster. Here's what the three different scenarios would have paid off over the first 10 years of the mortgage:

After 10 years, the 15-year mortgage would have a much lower outstanding principal balance than the 30-year loans, and the slightly higher interest rate would result in a higher outstanding balance for the 30-year loan at 5% interest:

The effect of mortgage terms and interest rates can be seen in the total amount paid back to the bank at the end of the 15- or 30-year term. The shorter-term leads to much less interest being paid overall, and the slightly higher 5% rate eventually leads to about $40,000 more in interest over a 30-year term: