I am trying to write a math equation with PHP. The equation I need to write is:
(.0054 * 260000) / (1-1.0054^-360)
This equals: 1639.958570 (On my calculator)
With the script I am writing I have it as such:
$dec = .0054;
$amount = 260000;
$months = 360;
$equation = ($dec * $amount) / (1 - (1 + $dec)^-$months);
print $equation;
The answer I am getting when I do this is "-3.9"
Any idea what I'm doing wrong?
Try using the pow() function:
$equation = ($dec * $amount) / (1 - pow(1 + $dec, $months * -1));
You can not use ^ for power. Whay you are doing now is that you XOR instead.
Use pow for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With