fork 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 = 1000;
  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
1901.6
2940.9
9031.5908
stderr
PHP Notice:  Undefined variable: paymentTotal in /home/Sn8jbU/prog.php on line 8
PHP Notice:  Undefined variable: paymentTotal in /home/Sn8jbU/prog.php on line 8
PHP Notice:  Undefined variable: paymentTotal in /home/Sn8jbU/prog.php on line 8