fork(3) download
  1. <?php
  2.  
  3.  
  4. function pay($creditSum, $payout, $percent, $servicePay, $opening) {
  5. $creditSum = $creditSum + $opening;
  6. for ($i = 0; $i < 30; $i++) {
  7. if ($creditSum <= $payout) {
  8. $paymentTotal = $paymentTotal + $creditSum;
  9. break;
  10. } else {
  11. $creditSum = ($creditSum / 100 * (100 + $percent)) + $servicePay - $payout;
  12. $paymentTotal = $paymentTotal + $payout;
  13. }
  14. }
  15. return $paymentTotal;
  16. }
  17.  
  18. $creditSum = 40000;
  19. $payout = 5000;
  20.  
  21. $homoCredit = pay($creditSum, $payout, 4, 500, 0);
  22. $softbank = pay($creditSum, $payout, 3, 1000, 0);
  23. $strawberryBank = pay($creditSum, $payout, 2, 0, 7777);
  24.  
  25. echo "homoCredit: {$homoCredit} руб.\n";
  26. echo "softbank: {$softbank} руб.\n";
  27. echo "strawberryBank: {$strawberryBank} руб.\n";
  28.  
  29.  
Success #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
homoCredit: 55889.580917157 руб.
softbank: 59138.172065718 руб.
strawberryBank: 53491.2914054 руб.
stderr
PHP Notice:  Undefined variable: paymentTotal in /home/GrVwDQ/prog.php on line 13
PHP Notice:  Undefined variable: paymentTotal in /home/GrVwDQ/prog.php on line 13
PHP Notice:  Undefined variable: paymentTotal in /home/GrVwDQ/prog.php on line 13