# How to calculate total loan knowing only the APR, term and monthly payments?

I'm building a loan calculator with two different methods of user entry. One one side the user can enter their desired loan amount and specify a term and it will display the overall loan amount and monthly payments.

The formula for this is:

Monthly Payments:(TotalAmount/Term)+(((TotalAmount*APR)/100)/12)

Total Loan: MonthlyPayments*Term

The trouble I am having is working out the alternative formula.

The second option of the calculator is for the user to specify a Monthly Payment and a Term (APR is a fixed, known rate).

Using only the Monthly Payment and the Term (plus a fixed APR rate) how can I determine what the actual loan amount (not the full payable amount, but the amount they are borrowing) the person will receive?

My current calculation is just MonthlyPayments*Term but this doesn't work because the monthly payment amount already has the APR figure within it. And I don't know how to determine the monthly APR because I don't know what the total loan amount actually is.

MonthlyPayment*(1-(1+((APR/12)/100)^-Term)/((APR/12)/100))