fork(4) download
  1. <?php
  2.  
  3.  
  4. function paymentSum($sum, $payout, $percent, $commission) {
  5. $paymentTotal=0;
  6. for ($i=1; $i>0; $i++) {
  7. $sum = $sum + $sum * $percent/100 + $commission - $payout;
  8. $paymentTotal = $paymentTotal + $payout;
  9. if ($sum == 0) {
  10. break;
  11. } elseif ($sum + $sum * $percent/100 + $commission < $payout) {
  12. $payout = $sum + $sum * $percent/100 + $commission;
  13. }
  14. }
  15. return $paymentTotal;
  16. }
  17.  
  18. $homoCreditTotal = paymentSum(39999, 5000, 4, 500);
  19. $softBankTotal = paymentSum(39999, 5000, 3,1000);
  20. $strawberryBankTotal = paymentSum(39999, 5000, 2, 0) + 7777;
  21.  
  22. echo"1 - $homoCreditTotal рублей\n";
  23. echo"2 - $softBankTotal рублей\n";
  24. echo"3 - $strawberryBankTotal рублей\n";
  25.  
  26. ?>
Success #stdin #stdout 0.01s 24400KB
stdin
Standard input is empty
stdout
1 - 56423.563121625 рублей
2 - 61268.718210807 рублей
3 - 51806.365496746 рублей