fork(2) download
  1. <?php
  2.  
  3. // IPAD
  4.  
  5.  
  6. function calculateTotalPayments($creditSum, $payout, $percent, $servicePayment){
  7.  
  8. $totalPayments = 0;
  9.  
  10. for ($month = 1; $month < 20; $month++){
  11. $creditSum = ($creditSum * $percent) + $servicePayment;
  12. if ($creditSum < $payout) {
  13. $payout = $creditSum;
  14. $creditSum -= $payout;
  15. } else {
  16. $creditSum -= $payout;
  17. }
  18.  
  19. $totalPayments += $payout;
  20.  
  21. if ($creditSum == 0) {
  22. break;
  23. }
  24. }
  25.  
  26. return $totalPayments;
  27.  
  28. }
  29.  
  30. $creditSum = 39999;
  31. $payout = 5000;
  32.  
  33. $homoCreditTotal= calculateTotalPayments($creditSum, $payout, 1.04, 500);
  34. $softbankTotal= calculateTotalPayments($creditSum, $payout, 1.03, 1000);;
  35. $strawberryBankTotal=calculateTotalPayments($creditSum + 7777, $payout, 1.02, 0);;
  36.  
  37. echo "homoCredit: {$homoCreditTotal} руб.\n";
  38. echo "softbank: {$softbankTotal} руб.\n";
  39. echo "strawberryBank: {$strawberryBankTotal} руб.\n";
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softbank: 61268.718210807 руб.
strawberryBank: 53559.8738592 руб.