fork(2) download
  1. <?php
  2.  
  3.  
  4. function countTotalCost ($percent, $serviceFee) {
  5. for ($months = 2, $debt = 39999, $monthlyPayment = 5000, $paymentTotal = 0; $months < 32; $months++) {
  6. $debt = $debt + ($debt * $percent) + $serviceFee - 5000;
  7. $paymentTotal = $paymentTotal + $monthlyPayment;
  8. if ($serviceFee == 7777) {
  9. $debt = $debt - $serviceFee;
  10. }
  11. if ($debt + ($debt * $percent) + $serviceFee < $monthlyPayment) {
  12. $paymentTotal = $paymentTotal + $debt + ($debt * $percent) + $serviceFee;
  13. $months++;
  14. break;
  15. }
  16. }
  17. return $paymentTotal;
  18. }
  19.  
  20. $creditSum = 39999;
  21. $payOut = 5000;
  22. $homoCreditTotal = countTotalCost (1.04, 500);
  23. $softBankTotal = countTotalCost (1.03, 1000);
  24. $strawberryBankTotal = countTotalCost (1.02, 7777);
  25.  
  26.  
  27. echo "If you go to HomoCredit you'll pay {$homoCreditTotal} rubles eventually \n";
  28. echo "If you go to SoftBank you'll pay {$softBankTotal} rubles eventually \n";
  29. echo "If you go to StawberryBank you'll pay {$strawberryBankTotal} rubles eventually \n";
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
If you go to HomoCredit you'll pay 150000 rubles eventually 
If you go to SoftBank you'll pay 150000 rubles eventually 
If you go to StawberryBank you'll pay 150000 rubles eventually