fork(1) download
  1. <?php
  2.  
  3.  
  4. function calcCredit($creditSum, $firstPayment, $monthlyPayment, $percent, $payout) {
  5. $payment = $creditSum + $firstPayment;
  6. echo "paymet = {$payment}\n";
  7. $totalPayout = 0;
  8.  
  9. for (;;) {
  10. echo "paymnet = $payment";
  11. echo "payout = $payout";
  12. $payment = $payment * $pecent + $monthlyPayment;
  13. if ($payment >= $payout) {
  14. $payment -= $payout;
  15. $totalPayout += $payout;
  16. } else {
  17. $totalPayout += $payment;
  18. break;
  19. }
  20. }
  21.  
  22. return $totalPayout;
  23. }
  24.  
  25. $creditSum = 40000;
  26. $payout = 5000;
  27. $homoCretidTotal = calcCredit($creditSum, 0, 500, 1.04, $payout);
  28. $softBankTotal = calcCredit($creditSum, 0, 1000, 1.03, $payout);
  29. $strawberryBankTotal = calcCredit($creditSum, 7777, 0, 1.02, $payout);
  30.  
  31. echo "homoCredit = {$homoCretidTotal}\n";
  32. echo "softBank = {$softBankTotal}\n";
  33. echo "strawberryBank = {$strawberryBankTotal}\n";
  34.  
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
paymet = 40000
paymnet = 40000payout = 5000paymet = 40000
paymnet = 40000payout = 5000paymet = 47777
paymnet = 47777payout = 5000homoCredit = 500
softBank = 1000
strawberryBank = 0
stderr
PHP Notice:  Undefined variable: pecent in /home/fHDWZ1/prog.php on line 13
PHP Notice:  Undefined variable: pecent in /home/fHDWZ1/prog.php on line 13
PHP Notice:  Undefined variable: pecent in /home/fHDWZ1/prog.php on line 13