**HP Prime: Length of a Loan with a Certain Payment**

**Introduction**

The program PMTLENGTH will calculate how many payments that
are required to finish a loan, given a certain annual interest rate and
payment. Payments are assumed to be
monthly, and end of period. The program
will also return the last payment. Due
to the rounding in the financial algorithms, the last payment is an approximate
(unless the interest rate is 0%).

Input:
PMTLENGTH(I,P,X)

I = annual interest rate

P = loan amount

X = payment amount, enter as a negative amount

Firmware 13441 or later is required.

**HP Prime Program PMTLENGTH**

EXPORT
PMTLENGTH(I,P,X)

BEGIN

// I%YR, PV, PMT (as negative)

// 2018-03-19 EWS

// how many monthly payments?

// last payment? (FV)

LOCAL N,B;

N:=Finance.TvmNbPmt(I,P,X,0,12);

B:=P;

IF FP(N)≠0 THEN

B:=Finance.TvmFV(IP(N),I,P,X,12);

N:=IP(N)+1;

END;

// {N, final pmt}

RETURN {N,B};

END;

**Examples**

Example 1: How long
will I take to pay off a $2,000 loan if I make $600 payments each month? This is a no interest loan.

Result: {4, -200}

It will take 4 payments, with the last payment being $200.

Example 2: How long
will I take to pay off a $5,350 loan if I make $750 monthly payments each
month? The loan has a 10% monthly
interest rate.

Result: {8,
-286.906502677}

It will take 8 payments, with the last payment being about
$286.91.

Eddie

This blog is property of Edward Shore, 2018.

## No comments:

## Post a Comment