fork(1) download
  1. <?php
  2.  
  3.  
  4. $credit = 40000;
  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 24400KB
stdin
Standard input is empty
stdout
Anon paid for 13 month. 
 Whole sum: 61270.186744521.
 Credit: 0 

Current month sum: 42200 
Sum, after anon paid: 37200 
Current month 1

Current month sum: 39316 
Sum, after anon paid: 34316 
Current month 2

Current month sum: 36345.48 
Sum, after anon paid: 31345.48 
Current month 3

Current month sum: 33285.8444 
Sum, after anon paid: 28285.8444 
Current month 4

Current month sum: 30134.419732 
Sum, after anon paid: 25134.419732 
Current month 5

Current month sum: 26888.45232396 
Sum, after anon paid: 21888.45232396 
Current month 6

Current month sum: 23545.105893679 
Sum, after anon paid: 18545.105893679 
Current month 7

Current month sum: 20101.459070489 
Sum, after anon paid: 15101.459070489 
Current month 8

Current month sum: 16554.502842604 
Sum, after anon paid: 11554.502842604 
Current month 9

Current month sum: 12901.137927882 
Sum, after anon paid: 7901.137927882 
Current month 10

Current month sum: 9138.1720657184 
Sum, after anon paid: 4138.1720657184 
Current month 11

Current month sum: 5262.31722769 
Sum, after anon paid: 262.31722768997 
Current month 12

Current month sum: 1270.1867445207 
Sum, after anon paid: 0
Current month 13

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