fork download
  1. <?php
  2.  
  3.  
  4. $target = 1000000; /* цель */
  5. $balance = 10000; /* вклад */
  6. $percent = 1.10; /* проценты */
  7. $yearsOld = 16; /* возраст */
  8.  
  9. for ($years = 1; $years<= 100; $years++) {
  10. $balance = $balance * $percent;
  11. $yearsOld = $yearsOld + 1;
  12.  
  13. if ($balance >= $target) {
  14. echo "прошло лет = {$years}, возраст = {$yearsOld}, выплачено = {$balance}";
  15. break;
  16. }
  17. }
Success #stdin #stdout 0.01s 24448KB
stdin
Standard input is empty
stdout
прошло лет =  49, возраст = 65, выплачено = 1067189.5716336