fork download
  1. <?php
  2.  
  3.  
  4. $credit = 1000;
  5. $percent = 0.03;
  6. $commission = 1000;
  7. $payment = 5000;
  8.  
  9. $rate = 1 + $percent;
  10.  
  11. do {
  12. $credit = $credit * $rate + $commission;
  13. $log .= "Current month sum: $credit \n";
  14.  
  15. $credit -= $payment;
  16. $log .= "Sum, after anon paid: $credit \n";
  17.  
  18. $period++;
  19. $log .= "Current month $period\n\n";
  20.  
  21. } while (($credit * $rate + $commission) > $payment);
  22.  
  23. $credit = $credit * $rate + $commission;
  24.  
  25. $log .= "Current month sum: $credit \n";
  26.  
  27. $sum = $period * $payment + $credit;
  28. $credit = 0;
  29. $period++;
  30.  
  31. $log .= "Sum, after anon paid: $credit\n"."Current month $period\n\n";
  32.  
  33. echo "Anon paid for $period month. \n Whole sum: $sum.\n Credit: $credit \n\n";
  34. echo $log;
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
Anon paid for 2 month. 
 Whole sum: 2940.9.
 Credit: 0 

Current month sum: 2030 
Sum, after anon paid: -2970 
Current month 1

Current month sum: -2059.1 
Sum, after anon paid: 0
Current month 2

stderr
PHP Notice:  Undefined variable: log in /home/c1otnL/prog.php on line 14
PHP Notice:  Undefined variable: period in /home/c1otnL/prog.php on line 19