fork download
  1. <?php
  2.  
  3.  
  4. $creditBalance = 40000;
  5. $percent = 1.03;
  6. $servicePayment = 1000;
  7. $monthlyPayment = 5000;
  8. $paymentTotal = 0;
  9.  
  10. for ($mouth = 1; $creditBalance > 0; $mouth++) {
  11. $creditBalance = ($creditBalance * $percent) + $servicePayment;
  12. $paymentTotal = $paymentTotal + $monthlyPayment;
  13. if ($creditBalance >= $monthlyPayment) {
  14. $creditBalance -= $monthlyPayment;
  15. break;
  16. }
  17. echo "{$mouth} месяц спустя, анон должен банку {$creditBalance}, всего внесено {$paymentTotal}\n";
  18. if ($creditBalance < $monthlyPayment) {
  19. $monthlyPayment=$creditBalance;
  20. break;
  21. }
  22.  
  23. if ($creditBalance == 0) {
  24. echo"Анон все выплатил";
  25. break;
  26. }
  27.  
  28. }
  29.  
  30. ?>
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout