Hello,
Not being an expert at java script or php for that matter I am having a difficult time at what I am sure most would feel to be easy. I have found a short script that solves for i in a loan calculation. i being the interest rate given pmt, pv, and nper. If someone is so inclined could you help me convert it to php.
function findi(p,lasti,pmt,n)
{
var i = (pmt(1-Math.pow((1+lasti),-n)))/p;
return i;
}
function computei()
{
var h = document.LOANI;
var ppy = parseFloath.payperyr.value);
var p = parseFloat(h.princ.value);
var n = parseFloat(h.n.value);
var lasti = n;
var pmt = parseFloat(h.pmt.value);
var count = 0;
var i;
while ( 1 ) {
i = findi(p,lasti,pmt,n);
if ( ppy100Math.abs( lasti-i) < .0000001 ) break;
lasti = i;
count = count + 1;
if ( count > 500 ) break;
}
if ( count > 500 ) {
h.fint.value = "-";
h.count.value = "NoConvrgnc";
}
else {
h.fint.value=ippy*100;
h.count.value=count;
}
}
ie p=100000, n=180, pmt=955.67 should equal 8%