fork download
  1. <?php
  2.  
  3. $credit = 40000;
  4. $percent = 0.03;
  5. $commission = 1000;
  6. $payment = 5000;
  7.  
  8. $rate = 1 + $percent;
  9.  
  10. do {
  11. $credit = $credit * $rate + $commission;
  12. $log .= "Current month sum: $credit <br />";
  13.  
  14. $credit -= $payment;
  15. $log .= "Sum, after anon paid: $credit <br />";
  16.  
  17. $period++;
  18. $log .= "Current month $period<br />";
  19.  
  20. } while (($credit * $rate + $commission) > $payment);
  21.  
  22. $period++;
  23. $log .= "Current month sum: $credit <br />";
  24.  
  25. $sum = $period * $payment + $credit;
  26. $credit = 0;
  27. $log .= "Sum, after anon paid: $credit <br /> Current month $period<br />";
  28.  
  29. echo "Anon paid for $period month. <br /> Whole sum: $sum.<br /> Credit: $credit";
  30. echo '<hr />';
  31. echo $log;
Success #stdin #stdout #stderr 0.01s 24400KB
stdin
Standard input is empty
stdout
Anon paid for 13 month. <br /> Whole sum: 65262.31722769.<br /> Credit: 0<hr />Current month sum: 42200 <br />Sum, after anon paid: 37200 <br />Current month 1<br />Current month sum: 39316 <br />Sum, after anon paid: 34316 <br />Current month 2<br />Current month sum: 36345.48 <br />Sum, after anon paid: 31345.48 <br />Current month 3<br />Current month sum: 33285.8444 <br />Sum, after anon paid: 28285.8444 <br />Current month 4<br />Current month sum: 30134.419732 <br />Sum, after anon paid: 25134.419732 <br />Current month 5<br />Current month sum: 26888.45232396 <br />Sum, after anon paid: 21888.45232396 <br />Current month 6<br />Current month sum: 23545.105893679 <br />Sum, after anon paid: 18545.105893679 <br />Current month 7<br />Current month sum: 20101.459070489 <br />Sum, after anon paid: 15101.459070489 <br />Current month 8<br />Current month sum: 16554.502842604 <br />Sum, after anon paid: 11554.502842604 <br />Current month 9<br />Current month sum: 12901.137927882 <br />Sum, after anon paid: 7901.137927882 <br />Current month 10<br />Current month sum: 9138.1720657184 <br />Sum, after anon paid: 4138.1720657184 <br />Current month 11<br />Current month sum: 5262.31722769 <br />Sum, after anon paid: 262.31722768997 <br />Current month 12<br />Current month sum: 262.31722768997 <br />Sum, after anon paid: 0 <br /> Current month 13<br />
stderr
PHP Notice:  Undefined variable: log in /home/iRnYxl/prog.php on line 13
PHP Notice:  Undefined variable: period in /home/iRnYxl/prog.php on line 18