fork(2) download
  1. <?php
  2. function countMoney($creditSum, $initialFee, $percent, $comission, $payment, $payout)
  3. {
  4. $creditSum = $creditSum + $initialFee;
  5. $percent = $percent + 100;
  6. for ($i = 1; $i <= 20; $i++) {
  7. $creditSum = $creditSum * $percent / 100 + $comission - $payout;
  8. $payment = $i * $payout;
  9. if ($creditSum * $percent / 100 + $comission < 5000) {
  10. $payment = $payment + ($creditSum * $percent / 100 + $comission);
  11. break;
  12. }
  13. }
  14. return $payment;
  15. }
  16. //variables
  17. $creditSum = 39999;
  18. $payout = 5000;
  19. $payment = 0;
  20. $homocredit = countMoney($creditSum, 0, 4, 500, $payment, $payout);
  21. echo "HomoCredit: {$homocredit} рублей.\n";
  22. $softbank = countMoney($creditSum, 0, 3, 1000, $payment, $payout);
  23. echo "SoftBank: {$softbank} рублей.\n";
  24. $stawberrybank = countMoney($creditSum, 7777, 2, 0, $payment, $payout);
  25. echo "StrawberryBank: {$stawberrybank} рублей.\n";
  26. $benefit = min($homocredit, $softbank, $stawberrybank);
  27. echo "Наивыгодный кредит - {$benefit}!";
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
HomoCredit: 56423.563121625 рублей.
SoftBank: 61268.718210807 рублей.
StrawberryBank: 53559.8738592 рублей.
Наивыгодный кредит - 53559.8738592!