fork download
  1. <?php
  2.  
  3.  
  4. function credit($summa, $persent, $plusVMesyac, $nachalniyVznos, $plataVMes)
  5. {
  6.  
  7. $vsyaSumma = $summa + $nachalniyVznos;
  8. $skolkoViplatil = 0;
  9. for ($i = 1; $i <= 100; $i++) {
  10. $vsyaSumma = ($vsyaSumma * $persent + $plusVMesyac);
  11.  
  12. if ($vsyaSumma > $plataVMes) {
  13. $vsyaSumma = $vsyaSumma - $plataVMes;
  14. } else {
  15. $plataVMes = $vsyaSumma;
  16. $vsyaSumma = $vsyaSumma - $plataVMes;
  17. }
  18. $skolkoViplatil = $skolkoViplatil + $plataVMes;
  19.  
  20.  
  21. if ($vsyaSumma <= 0) {
  22. return $skolkoViplatil;
  23. break;
  24. }
  25. }
  26. }
  27.  
  28.  
  29. $creditsum = 39999;
  30. $payount = 5000;
  31. $homoCreditTotal = credit($creditsum, 1.04, 500, 0, $payount);
  32. $softBankTotal = credit($creditsum, 1.03, 1000, 0, $payount);
  33. $strawberryBankTotal = credit($creditsum, 1.02, 0, 7777, $payount);
  34.  
  35. echo "homoCredit: {$homoCreditTotal} рублей \n";
  36. echo "softBankTotal: {$softBankTotal} рублей\n";
  37. echo "strawberryBankTotal: {$strawberryBankTotal} рублей \n";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 рублей 
softBankTotal: 61268.718210807 рублей
strawberryBankTotal: 53559.8738592 рублей