fork 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. }
  15. $creditSum -= $payout;
  16.  
  17. $totalPayments += $payout;
  18.  
  19. if ($creditSum <= 0) {
  20. break;
  21. }
  22. }
  23.  
  24. return $totalPayments;
  25.  
  26. }
  27.  
  28. $creditSum = 39999;
  29. $payout = 5000;
  30.  
  31. $homoCreditTotal= calculateTotalPayments($creditSum, $payout, 1.04, 500);
  32. $softbankTotal= calculateTotalPayments($creditSum, $payout, 1.03, 1000);;
  33. $strawberryBankTotal=calculateTotalPayments($creditSum + 7777, $payout, 1.02, 0);;
  34.  
  35. echo "homoCredit: {$homoCreditTotal} руб.\n";
  36. echo "softbank: {$softbankTotal} руб.\n";
  37. echo "strawberryBank: {$strawberryBankTotal} руб.\n";
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softbank: 61268.718210807 руб.
strawberryBank: 53559.8738592 руб.