fork download
  1. <?php
  2.  
  3.  
  4. function getBalance($percent, $commission) {
  5. $paymentTotal=0;
  6. $creditSum=39999;
  7. $payout=5000;
  8.  
  9. for($month=0;$month<=20;$month++){
  10. $creditSum=$creditSum*$percent+$commission;
  11.  
  12. if($creditSum<$payout) {
  13. $paymentTotal+=$creditSum;
  14. $creditSum=0;
  15. break;
  16. }
  17. else{
  18. $creditSum-=$payout;
  19. $paymentTotal+=$payout;
  20. }
  21. }
  22. return $paymentTotal;
  23. }
  24. $homoCreditTotal=getBalance(1.04, 500);
  25. $softBankTotal=getBalance(1.03, 1000);
  26. $strawberryBankTotal=getBalance(1.02, 0) + 7777;
  27.  
  28. echo "homoCredit: {$homoCreditTotal} руб.\n";
  29. echo "softBank: {$softBankTotal} руб.\n";
  30. echo "strawberryBank: {$strawberryBankTotal} руб.\n";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softBank: 61268.718210807 руб.
strawberryBank: 51806.365496746 руб.