fork download
  1. <?php
  2.  
  3.  
  4. function getBalance($creditBalance, $monthlyPayment, $percent, $servicePayment, $paymentTotal) {
  5.  
  6. for ($month = 1; $month <= 20; $month ++) {
  7.  
  8. $creditBalance = ( $creditBalance * $percent ) + $servicePayment;
  9.  
  10. if ($creditBalance < $monthlyPayment) {
  11. $monthlyPayment = $creditBalance;
  12. }
  13. $paymentTotal = $paymentTotal + $monthlyPayment;
  14. $creditBalance -= $monthlyPayment;
  15.  
  16. if ($creditBalance <= 0) {
  17. break;
  18. }
  19. }
  20. return $paymentTotal;
  21. }
  22.  
  23. $creditBalance = 39999; /* Долг анона перед банком */
  24. $monthlyPayment = 5000; /* Анон платит 5000 р в месяц, это все, что ему дает мама на завтраки */
  25. $homoCreditTotal = getBalance($creditBalance, $monthlyPayment, 1.04, 500, 0);
  26. $softbankTotal = getBalance($creditBalance, $monthlyPayment, 1.03, 1000, 0);
  27. $strawberryBankTotal = getBalance($creditBalance + 7777, $monthlyPayment, 1.02, 0, 0);
  28.  
  29. echo "homoCredit: {$homoCreditTotal}\n";
  30. echo "softbank: {$softbankTotal}\n";
  31. echo "strawberryBank: {$strawberryBankTotal}\n";
Success #stdin #stdout 0.01s 24448KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625
softbank: 61268.718210807
strawberryBank: 53559.8738592