fork(1) download
  1. <?php
  2.  
  3.  
  4. function chooseBank($percent, $comission, $openPayment) {
  5.  
  6. $creditSum = 39999;
  7. $payout = 5000;
  8. $totalPayment = 0 + $openPayment;
  9. for ($i = 1; $creditSum > 0; $i++) {
  10. $monthlyPayment = $creditSum * $percent + $comission;
  11. $creditSum = $creditSum + $monthlyPayment;
  12. if ($creditSum < 5000) {
  13. $payout = $creditSum;
  14. $creditSum = $creditSum - $payout;
  15. $totalPayment = $totalPayment + $payout;
  16. break;
  17. }
  18. $creditSum = $creditSum - $payout;
  19. $totalPayment = $totalPayment + $payout;
  20. }
  21. return $totalPayment;
  22. }
  23.  
  24. $homoCreditTotal = chooseBank(0.04, 500, 0);
  25. $softbankTotal = chooseBank(0.03, 1000, 0);
  26. $strawberryBankTotal = chooseBank(0.02, 0, 7777);
  27.  
  28. echo "homoCredit: {$homoCreditTotal} руб.\n";
  29. echo "softbank: {$softbankTotal} руб.\n";
  30. echo "strawberryBank: {$strawberryBankTotal} руб.\n";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softbank: 61268.718210807 руб.
strawberryBank: 51806.365496746 руб.