fork download
  1. <?php
  2.  
  3. header("Content-Type: text/plain; charset=utf-8");
  4.  
  5. $monthlyPayment = 5000;
  6. $creditSum = 39999;
  7.  
  8. function getTotalAmountOfPayments($creditBalance, $paymentTotal, $percent, $servicePayment, $monthlyPayment) {
  9. do {
  10. $creditBalance = ( $creditBalance * $percent ) + $servicePayment;
  11.  
  12. if ($creditBalance <= $monthlyPayment) {
  13. $monthlyPayment = $creditBalance;
  14. }
  15. $creditBalance -= $monthlyPayment;
  16. $paymentTotal += $monthlyPayment;
  17. } while ($creditBalance > 0);
  18.  
  19. return $paymentTotal;
  20. }
  21.  
  22. $homoCreditTotal = getTotalAmountOfPayments($creditSum, 0, 1.04, 500, $monthlyPayment);
  23. $softBankTotal = getTotalAmountOfPayments($creditSum, 0, 1.03, 1000, $monthlyPayment);
  24. $strawberryBankCreditTotal = getTotalAmountOfPayments($creditSum, 7777, 1.02, 0, $monthlyPayment);
  25.  
  26. echo "Сумма выплат в первом банке - {$homoCreditTotal} \n";
  27. echo "Сумма выплат во втором банке - {$softBankTotal} \n";
  28. echo "Сумма выплат в третьем банке - {$strawberryBankCreditTotal} \n";
  29.  
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
Сумма выплат в первом банке - 56423.563121625 
Сумма выплат во втором банке - 61268.718210807 
Сумма выплат в третьем банке - 51806.365496746