From: Roland Haeder Date: Thu, 14 May 2015 18:01:22 +0000 (+0200) Subject: Adjusted a bit, still not accurate enough and may not reflect inflation X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=51ca33fca8cc2b2ead679e2bb8a166ed845c8c9f Adjusted a bit, still not accurate enough and may not reflect inflation correctly. Signed-off-by: Roland Häder --- diff --git a/contrib/exp/exp2.php b/contrib/exp/exp2.php index 22e985d3..03b7108a 100644 --- a/contrib/exp/exp2.php +++ b/contrib/exp/exp2.php @@ -12,11 +12,13 @@ $totalMonths = $years * 12; print 'Invest ' . $balance . ' EUR and come back later.' . PHP_EOL; for ($i = 1; $i <= $totalMonths; $i++) { - if ($i % 12 == 0) { - $rate = bcdiv($rate, 1.01); - } // END - if + // Reduce interest rate every month + $rate = bcdiv($rate, 1.001); + // Calculate interest $interest = bcmul($balance, $rate); + + // ... and add it to balance $balance = bcadd($balance, $interest); print 'Month ' . $i . ': rate=' . bcmul($rate, 100) . '%,interest=' . $interest . ',balance=' . $balance . PHP_EOL;