]> git.mxchange.org Git - core.git/blobdiff - contrib/exp/exp2.php
Continued:
[core.git] / contrib / exp / exp2.php
index b6040fc543f68f9407f21e13844cac84ae30bb27..c51211e0eb8b696efbb6f7736ba5721f084a4f92 100644 (file)
@@ -4,8 +4,8 @@ error_reporting(E_ALL | E_STRICT);
 bcscale(20);
 
 $balance = 1;
-$years = 100;
-$rate = 0.02;
+$years = 2017;
+$rate = 0.03;
 
 $totalMonths = $years * 12;
 
@@ -13,7 +13,7 @@ print 'Invest ' . $balance . ' EUR and come back later.' . PHP_EOL;
 
 for ($i = 1; $i <= $totalMonths; $i++) {
        // Reduce interest rate every month
-       $rate = bcdiv($rate, 1.001);
+       $rate = bcdiv($rate, 1.00001);
 
        // Calculate interest
        $interest = bcmul($balance, $rate);
@@ -22,9 +22,7 @@ for ($i = 1; $i <= $totalMonths; $i++) {
        $balance = bcadd($balance, $interest);
 
        print 'Month ' . $i . ': rate=' . bcmul($rate, 100) . '%,interest=' . $interest . ',balance=' . $balance . PHP_EOL;
-} // END - foreach
+}
 
 print 'After ' . $totalMonths . ' months (' . $years . ' years) you have ' . $balance . ' EUR back.' . PHP_EOL;
 //print 'Length:' . strlen($balance) . PHP_EOL;
-
-?>