fork download
  1. <?php
  2.  
  3. function countTotalPayment ($creditDebt, $percent, $serviceFee, $monthlyPayment, $separateChunk) {
  4. for ($months = 2, $creditDebt = $creditDebt + $separateChunk, $paymentTotal = 0; $months <= 20; $months ++) {
  5. $creditDebt = ($creditDebt * $percent) + $serviceFee - $monthlyPayment;
  6. $paymentTotal = $paymentTotal + $monthlyPayment;
  7. if (($creditDebt * $percent) + $serviceFee < $monthlyPayment) {
  8. $paymentTotal = $paymentTotal + ($creditDebt * $percent) + $serviceFee;
  9. $months++;
  10. break;
  11. }
  12. }
  13. return $paymentTotal;
  14. }
  15.  
  16. $creditSum = 1000;
  17. $payout = 5000;
  18. $homoCreditTotal = countTotalPayment ($creditSum, 1.04, 500, $payout, 0);
  19. $softbankTotal = countTotalPayment ($creditSum, 1.03, 1000, $payout, 0);
  20. $strawberryBankTotal = countTotalPayment ($creditSum, 1.02, 0, $payout, 7777);
  21.  
  22. echo "HomoCredit: {$homoCreditTotal} \n";
  23. echo "Softbank: {$softbankTotal} \n";
  24. echo "StrawberryBank: {$strawberryBankTotal} \n";
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
HomoCredit: 1901.6 
Softbank: 2940.9 
StrawberryBank: 9031.5908