* Amort.PRG * CALL = Do Amort WITH 1000,5,12 * do Amort with TotalLoaned,%Interest,Number of Payments * LPARAMETERS lnP,lnR,lnN lnR=lnR/100/12 && Annualize and correct for percent *!* lnP=Original Principal or Face *!* lnR=Interest Rate *!* lnN=Number of payment periods DIMENSION arAmort[lnN,5] *arAmort(n,1)=Total Monthly Payment *arAmort(n,2)=Interest payment *arAmort(n,3)=Principal Payment *arAmort(n,4)=Principal Balance *arAmort(n,5)=Pricipal factor lnPBal=lnP && Pricipal Balance FOR C=1 TO lnN * Total Monthly payment arAmort[c,1]=ROUND(lnPBal*(lnR*(1+lnR)**(lnN-C+1)) / ((1+lnR)**(lnN-C+1)-1),2) * Interest portion of payment arAmort[c,2]=ROUND(lnPBal*lnR,2) * Principal Portion of payment arAmort[c,3]=arAmort[c,1]-arAmort[c,2] * Principal Balance (current face) arAmort[c,4]=lnPBal-arAmort[c,3] && balance less period principal payment * Principal Factor arAmort[c,5]=ROUND(arAmort[c,4]/lnP,6) * Principal balance for next period's calculation lnPBal=arAmort[c,4] && Pricipal forward for next reiteration ENDFOR *!* lnTotalInterest=0 *!* FOR c=1 TO lnN *!* lnTotalInterest=lnTotalInterest+arAmort[c,2] *!* ENDFOR *!* ?lnTotalInterest disp MEMORY LIKE arAmort