fork(2) download
  1. <?php
  2.  
  3.  
  4. function getSum ($percent, $tax, $account, $creditSum, $payout) {
  5. $paymentTotal = 0;
  6. $creditSum = $creditSum + $account;
  7. for ($i ; $i < 100 ;$i++) {
  8. $creditBalance = $creditSum * $percent - $payout + $tax;
  9. //надо подумать над другим ограничением цикла
  10. $paymentTotal += $payout;
  11. $creditSum = $creditBalance;
  12. if ($creditBalance < 0) {
  13. $paymentTotal += $creditBalance;
  14. break;
  15. }
  16. }
  17. return $paymentTotal;
  18. }
  19. $creditSum = 39999;
  20. $payout = 5000;
  21.  
  22. $homoCreditBank = getSum (1.04, 500, 0, $creditSum, $payout);
  23. $softBank = getSum (1.03, 1000, 0, $creditSum, $payout);
  24. $StrawberryBankTotal = getSum (1.02, 0, 7777, $creditSum, $payout);
  25.  
  26. echo "homoCreditBank {$homoCreditBank} руб \n";
  27. echo "SoftBank {$softBank} руб \n";
  28. echo "StrawberryBankTotal {$StrawberryBankTotal} руб \n";
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
homoCreditBank 56423.563121625 руб 
SoftBank 61268.718210807 руб 
StrawberryBankTotal 53559.8738592 руб 
stderr
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8
PHP Notice:  Undefined variable: i in /home/t6s841/prog.php on line 8