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