fork download
  1. <?php
  2.  
  3.  
  4. function ioanCalc ($creditSum, $percent, $comission, $firstPay, $payout){
  5.  
  6. $totalPay = 0;
  7. $percentSum = $percent * ($creditSum + $firstPay)/100;
  8.  
  9. for ($i = 0; $creditSum > 0; $i++) {
  10. $creditSum = $creditSum + $comission + $percentSum;
  11. if ($creditSum < $payout) {
  12. $payout = $creditSum;
  13. }
  14. $creditSum = $creditSum - $payout;
  15. $totalPay = $totalPay + $payout;
  16. }
  17. return $totalPay;
  18. }
  19.  
  20. $creditSum = 39999;
  21. $payout = 5000;
  22. $totalPay = 0;
  23.  
  24. $homoCreditTotal = ioanCalc($creditSum, 4, 500, 0, $payout);
  25. $softbankTotal = ioanCalc($creditSum, 3, 1000, 0, $payout);
  26. $strawberrybankTotal = ioanCalc($creditSum, 2, 0, 7777, $payout);
  27.  
  28. echo "HomoCredit: {$homoCreditTotal}\n";
  29. echo "Softbank: {$softbankTotal}\n";
  30. echo "StrawberryBank: {$strawberrybankTotal}\n";
  31.  
  32.  
  33. ?>
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
69398.44
72998.55
49554.2