fork download
  1. <?php
  2.  
  3.  
  4. function countCyka($creditSum, $percent, $servicePayment, $payout, $firstPay){
  5. //echo "{$creditSum}, {$firstPay}\n";
  6. $creditSum = $creditSum + $firstPay;
  7. //echo "{$creditSum}\n";
  8. $totalPay = 0;
  9. for ($month=0; $month <=20; $month++){
  10. $creditSum = $creditSum + ($creditSum * $percent) + $servicePayment;
  11. if($creditSum < $payout){
  12. $payout = $creditSum;
  13. $creditSum = $creditSum - $payout;
  14. $totalPay = $totalPay + $payout;
  15. //echo "Ура, я расплатился! Потратил {$totalPay} рублей на эту срань!\n";
  16. break;
  17. } else {
  18. $creditSum = $creditSum - $payout;
  19. $totalPay = $totalPay + $payout;
  20. //echo "Выплатил уже {$totalPay}.\n";
  21. }
  22. }
  23. return $totalPay;
  24. }
  25.  
  26. $homoCreditTotal = countCyka(39999, 0.04, 500, 5000, 0);
  27. $softBankTotal = countCyka(39999, 0.03, 1000, 5000, 0);
  28. $strawberryBankTotal = countCyka(39999, 0.02, 0, 5000, 7777);
  29. echo "Homocredit: {$homoCreditTotal}.\n";
  30. echo "SoftBank: {$softBankTotal}.\n";
  31. echo "StrawberryBank: {$strawberryBankTotal}.\n";
  32. ?>
  33. // your code goes here
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
Homocredit: 56423.563121625.
SoftBank: 61268.718210807.
StrawberryBank: 53559.8738592.
// your code goes here