fork download
  1. <?php
  2.  
  3.  
  4. function getSum ($percent, $tax, $account, $creditSum, $payout) {
  5. $paymentTotal = 0;
  6. $creditSum = $creditSum + $account;
  7. if (($creditSum * ($percent - 1) + $tax) >= $payout) {
  8. $paymentTotal = 'Бесконечно';
  9. }
  10. else {
  11. for ( ; ; ) {
  12. $creditBalance = $creditSum * $percent - $payout + $tax;
  13. $paymentTotal += $payout;
  14. $creditSum = $creditBalance;
  15. if ($creditBalance < 0) {
  16. $paymentTotal += $creditBalance;
  17. $paymentTotal = round($paymentTotal,2);
  18. break;
  19. }
  20. }
  21. }
  22. return $paymentTotal;
  23. }
  24. $creditSum = 39999;
  25. $payout = 5000;
  26.  
  27. $homoCreditBank = getSum (1.04, 500, 0, $creditSum, $payout);
  28. $softBank = getSum (1.03, 1000, 0, $creditSum, $payout);
  29. $StrawberryBankTotal = getSum (1.02, 0, 7777, $creditSum, $payout);
  30.  
  31. echo "homoCreditBank $homoCreditBank руб \n";
  32. echo "SoftBank $softBank руб \n";
  33. echo "StrawberryBankTotal $StrawberryBankTotal руб \n";
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
homoCreditBank 56423.56 руб 
SoftBank 61268.72 руб 
StrawberryBankTotal 53559.87 руб