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;