fork(2) download
  1. <?php
  2.  
  3.  
  4. function totalPayment($creditSum, $percent, $monthlyPayment, $servicePayment, $newAccPayment) {
  5. $paymentTotal = 0;
  6. $creditSum += $newAccPayment;
  7. while ($creditSum > 0) {
  8. $creditSum = ($creditSum * $percent) + $servicePayment;
  9. if ($creditSum < $monthlyPayment) {
  10. $monthlyPayment = $creditSum;
  11. }
  12. $creditSum -= $monthlyPayment;
  13. $paymentTotal = $paymentTotal + $monthlyPayment;
  14. }
  15. return $paymentTotal;
  16. }
  17.  
  18. $creditSum = 39999;
  19. $monthlyPayment = 5000;
  20. $homoCredit = totalPayment($creditSum, 1.04, $monthlyPayment, 500, 0);
  21. $softBank = totalPayment($creditSum, 1.03, $monthlyPayment, 1000, 0);
  22. $strawberryBank = totalPayment($creditSum, 1.02, $monthlyPayment, 0, 7777);
  23. echo "homoCredit: {$homoCredit} roubles.\n";
  24. echo "softBank: {$softBank} roubles.\n";
  25. echo "strawberryBank: {$strawberryBank} roubles.\n";
  26.  
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 roubles.
softBank: 61268.718210807 roubles.
strawberryBank: 53559.8738592 roubles.