fork download
  1. <?php
  2.  
  3.  
  4.  
  5. function fcredit($credit, $percent, $comission) {
  6. for ($pay = 0; $credit >= 5000;) {
  7. $credit = $credit * $percent + $comission;
  8. $pay += 5000;
  9. $credit -= 5000;
  10. if ($credit < 5000) {
  11. $pay += $credit;
  12. $credit -= $credit;
  13. }
  14. }
  15. return $pay;
  16. }
  17.  
  18. $credit = 39999;
  19. $firstbank = fcredit($credit, 1.04, 500);
  20. $secondbank = fcredit($credit, 1.03, 1000);
  21. $thirdbank = fcredit($credit + 7777, 1.02, 0);
  22.  
  23. echo "homocredit: {$firstbank} rub\n";
  24. echo "softbank: {$secondbank} rub\n";
  25. echo "strawberrybank: {$thirdbank} rub\n";
Success #stdin #stdout 0.02s 24608KB
stdin
Standard input is empty
stdout
37098.96
34082.9184
30946.235136
27684.08454144
24291.447923098
20763.105840022
17093.630073622
13277.375276567
9308.47028763
5180.8090991352
888.04146310056
37198.97
34314.9391
31344.387273
28284.71889119
25133.260457926
21887.258271663
18543.876019813
15100.192300408
11553.19806942
7899.7940115026
4136.7878318477
43731.52
39606.1504
35398.273408
31106.23887616
26728.363653683
22262.930926757
17708.189545292
13062.353336198
8323.6004029218
3490.0724109802
homocredit: 55888.041463101 rub
softbank: 59136.787831848 rub
strawberrybank: 53490.07241098 rub