fork download
  1. <?php
  2.  
  3.  
  4. function countLoanCost($percent, $servicePayout, $openPayout, $creditSum, $maxPayout){
  5. $creditBalance = $creditSum + $openPayout;
  6. $paymentTotal = 0;
  7. for ( $month=1; $month <= 100000; $month++ ) {
  8. $creditBalance = round(($creditBalance * $percent) + $servicePayout, 2);
  9. $anonPays = min($maxPayout, $creditBalance);
  10. $creditBalance -= $anonPays;
  11. $paymentTotal += $anonPays;
  12. if ($creditBalance == 0) {
  13. break;
  14. }
  15. }
  16. return $paymentTotal;
  17. }
  18.  
  19. $creditSum = 39999;
  20. $maxPayout= 5000;
  21. $homoCreditTotal = countLoanCost(1.04, 500, 0, $creditSum, $maxPayout);
  22. $softBankTotal = countLoanCost(1.03, 1000, 0, $creditSum, $maxPayout);
  23. $strawberryBankTotal = countLoanCost(1.02, 0, 7777, $creditSum, $maxPayout);
  24.  
  25. echo "HomoCredit : {$homoCreditTotal} руб.\n";
  26. echo "SoftBank : {$softBankTotal} руб.\n";
  27. echo "StrawberryBank : {$strawberryBankTotal} руб.\n";
  28.  
  29. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
HomoCredit : 56423.57 руб.
SoftBank :  61268.73 руб.
StrawberryBank : 53559.87 руб.