Re: Mathematical prob

From: Date: Tue, 13 Feb 2001 05:56:18 +0000
Subject: Re: Mathematical prob
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39358@lists.php.net to get a copy of this message
> Okay, im a little stumped. I have been asked to use a formula which > calculates Monthly Repayments on a mortgage loan. The formula I have been > given is > > M = P * ( J / (1 - (1 + J) ** -N)) > > My problem is, the last part. It explains it in english as "then take that > to the -N (minus N) power" > > My problem is, I have no idea how to put this into a PHP script so that it > can calculate it out. I have a feeling im falling short at the "to the > power of" part. I tried to do a 3 to the power of 3 calculation and I cant > get it to spit out 27 like I know it should. > Chris, I think this is what you're looking for: <?PHP echo "<html><body>"; // principle $P = 180000; // annual rate divided by 12 months $J = 0.0775/12; // 30 years times 12 months $N = 360; // monthly payment $M = $P*($J/(1-pow((1+$J),-$N))); echo $M; echo "</body></html>"; ?> Hope this helps, Joe

« previous php.general (#39358) next »