fork(4) download
  1. <?php
  2.  
  3. function getBalanceInFuture($credit, $payment, $commission, $percent, $newAccount ) {
  4. $credit = $credit + $newAccount;
  5. for ( $i = 0; $i<= 100; $i++) {
  6. $credit = ($credit * $percent) + $commission - $payment;
  7. $paymentTotal = $paymentTotal + $payment;
  8. $creditNext = ($credit * $percent) + $commission - $payment;
  9. if ( $creditNext<=0 ) {
  10. $paymentTotal=$paymentTotal + ($credit * $percent) + $commission;
  11. break;
  12. }
  13. }
  14. return $paymentTotal;
  15. }
  16. $credit = 39999;
  17. $payment = 5000;
  18. $homoCredit = getBalanceInFuture($credit, $payment ,500 , 1.04, 0 );
  19. $softBank = getBalanceInFuture($credit, $payment ,1000 , 1.03, 0 );
  20. $strawberryBank = getBalanceInFuture($credit, $payment ,0 , 1.02, 7777 );
  21.  
  22. echo "$homoCredit\n";
  23. echo "$softBank\n";
  24. echo "$strawberryBank\n";
Success #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
56423.563121625
61268.718210807
53559.8738592
stderr
PHP Notice:  Undefined variable: paymentTotal in /home/LwUcTo/prog.php on line 9
PHP Notice:  Undefined variable: paymentTotal in /home/LwUcTo/prog.php on line 9
PHP Notice:  Undefined variable: paymentTotal in /home/LwUcTo/prog.php on line 9