all these scripts are provided AS IS AND WITHOUT ANY WARRANTY.
Signed-off-by: Roland Häder <roland@mxchange.org>
--- /dev/null
+These contributed codes, mostly by myself, are for testing/experimenting
+purposes only and are provided "AS IS" and "WITHOUT ANY WARRANTY".
\ No newline at end of file
+++ /dev/null
-These contributed codes, mostly by myself, are for testing/experimenting
-purposes only and are provided "AS IS" and "WITHOUT ANY WARRANTY".
\ No newline at end of file
--- /dev/null
+<?php
+error_reporting(E_ALL | E_STRICT);
+
+print 'Eat 1 apple at the first day and next day eat twice!' . PHP_EOL;
+
+$years = 100;
+$m = $years / 4;
+
+$totalDays = ($years * 365 + $m);
+
+$x = 1; $y = 0;
+for ($i = 1; $i <= $totalDays; $i++) {
+ $x = bcmul($x, 2);
+ $y = bcadd($y, $x);
+} // END - foreach
+
+print 'After ' . $totalDays . ' days (' . $years . ' years) you have eaten ' . $y . ' fruits.' . PHP_EOL;
+print 'Length:' . strlen($y) . PHP_EOL;
+
+?>
--- /dev/null
+<?php
+error_reporting(E_ALL | E_STRICT);
+
+bcscale(20);
+
+$balance = 1;
+$years = 100;
+$rate = 0.05;
+
+$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
+
+ $interest = bcmul($balance, $rate);
+ $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;
+
+?>
+++ /dev/null
-<?php
-error_reporting(E_ALL | E_STRICT);
-
-$prev = 1;
-$fib = 1;
-
-for ($idx = 0; $idx < 100000; $idx++) {
- $diff = bcdiv($fib, $prev, 500);
-
- print 'idx=' . $idx . PHP_EOL;
- print 'fib=' . $fib . PHP_EOL;
- print 'prev=' . $prev . PHP_EOL;
- print 'diff=' . $diff . PHP_EOL;
-
- $sum = bcadd($prev, $fib);
- $prev = $fib;
- $fib = $sum;
-}
-
-?>
--- /dev/null
+<?php
+error_reporting(E_ALL | E_STRICT);
+
+$prev = 1;
+$fib = 1;
+
+for ($idx = 0; $idx < 100000; $idx++) {
+ $diff = bcdiv($fib, $prev, 500);
+
+ print 'idx=' . $idx . PHP_EOL;
+ print 'fib=' . $fib . PHP_EOL;
+ print 'prev=' . $prev . PHP_EOL;
+ print 'diff=' . $diff . PHP_EOL;
+
+ $sum = bcadd($prev, $fib);
+ $prev = $fib;
+ $fib = $sum;
+}
+
+?>