fork(3) download
  1. <?php
  2.  
  3.  
  4. function countTotalPayment ($creditDebt, $percent, $serviceFee, $monthlyPayment) {
  5. for ($months = 2, $paymentTotal = 0; $months <= 20; $months ++) {
  6. $creditDebt = ($creditDebt * $percent) + $serviceFee - $monthlyPayment;
  7. $paymentTotal = $paymentTotal + $monthlyPayment;
  8. if ($serviceFee == 7777 && $months > 3) {
  9. $creditDebt = $creditDebt - $serviceFee;
  10. }
  11. if (($creditDebt * $percent) + $serviceFee < $monthlyPayment) {
  12. $paymentTotal = $paymentTotal + ($creditDebt * $percent) + $serviceFee;
  13. $months++;
  14. break;
  15. }
  16. }
  17. return $paymentTotal;
  18. }
  19.  
  20. $creditSum = 40000;
  21. $payout = 5000;
  22. $homoCreditTotal = countTotalPayment ($creditSum, 1.04, 500, $payout);
  23. $softbankTotal = countTotalPayment ($creditSum, 1.03, 1000, $payout);
  24. $strawberryBankTotal = countTotalPayment ($creditSum, 1.02, 7777, $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: 56425.164153843 
Softbank: 61270.186744521 
StrawberryBank: 70466.614057312