fork download
  1. <?php
  2.  
  3.  
  4. function countTotal($sum, $percent, $comm, $also, $pay) {
  5. $total = 0;
  6. $sum += $also;
  7. for (; $sum > 0;) {
  8. $sum = $sum * $percent + $comm;
  9. if ($sum > $pay) {
  10. $total += $pay;
  11. $sum -= $pay;
  12. } else {
  13. $total += $sum;
  14. $sum = 0;
  15. }
  16. }
  17. return $total;
  18. }
  19.  
  20. $creditSum = 39999;
  21. $payout = 5000;
  22. $homoCreditTotal = countTotal($creditSum, 1.04, 500, 0, $payout);
  23. $softBankTotal = countTotal($creditSum, 1.03, 1000, 0, $payout);
  24. $strawberryBankTotal = countTotal($creditSum, 1.02, 0, 7777, $payout);
  25.  
  26. echo "homoCreditTotal: {$homoCreditTotal} руб.\n";
  27. echo "softBankTotal: {$softBankTotal} руб.\n";
  28. echo "strawberryBankTotal: {$strawberryBankTotal} руб.\n";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homoCreditTotal: 56423.563121625 руб.
softBankTotal: 61268.718210807 руб.
strawberryBankTotal: 53559.8738592 руб.