From 51ca33fca8cc2b2ead679e2bb8a166ed845c8c9f Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 14 May 2015 20:01:22 +0200 Subject: [PATCH] Adjusted a bit, still not accurate enough and may not reflect inflation correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- contrib/exp/exp2.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; -- 2.39.2