fork download
  1. <?php
  2.  
  3.  
  4. function calcCredit($creditSum, $payout, $percent, $comissionPayment, $openPayment, $paymentTotal = 0) {
  5. $creditSum += $openPayment;
  6. for($month = 1; $creditSum > 0; $month ++) {
  7. $creditSum = ($creditSum * $percent) + $comissionPayment;
  8. if($creditSum < $payout) {
  9. $payout = $creditSum;
  10. }
  11. $creditSum -= $payout;
  12. $paymentTotal += $payout;
  13. }
  14. return $paymentTotal;
  15. }
  16.  
  17. $homoCreditTotal = calcCredit(39999, 5000, 1.04, 500, 0);
  18. $softBankTotal = calcCredit(39999, 5000, 1.03, 1000, 0);
  19. $strawberryBankTotal = calcCredit(39999, 5000, 1.02, 0, 7777);
  20.  
  21. echo "homoCredit: {$homoCreditTotal} руб.\n";
  22. echo "softBank: {$softBankTotal} руб.\n";
  23. echo "strawberryBank: {$strawberryBankTotal} руб.\n";
  24.  
  25. ?>
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softBank: 61268.718210807 руб.
strawberryBank: 53559.8738592 руб.