Find the largest loan a monthly payment you can afford will repay at a given rate and term.
Model and assumptions. The largest loan is the present value of the payments: the monthly payment times (1 minus (1 plus the monthly rate) to the power of minus the number of months), divided by the monthly rate. The monthly rate is the annual rate divided by 12. At a 0% rate the loan is simply the payment times the number of months. The model assumes level payments at the end of each month and ignores fees, taxes and insurance that a lender may add to the payment.