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