fork(1) download
  1. <?php
  2. function bankPayments ($percent, $comission, $oncePayment){
  3. $credit = 39999;
  4. $payment = 5000;
  5. $k = 0;
  6. $credit+=$oncePayment;
  7. for ($i=0; $credit != 0; $i++){
  8. $credit += $credit*$percent + $comission;
  9. if($credit<$payment and $credit != 0){
  10.  
  11. $lastPayment = $credit;
  12.  
  13.  
  14. // echo"Credit $credit \n";
  15.  
  16. $credit = $credit - $lastPayment;
  17.  
  18. $summ = $payment*$k+$lastPayment;
  19.  
  20. echo "Summary $summ \n";
  21.  
  22. // echo "Last Payment $lastPayment \n";
  23.  
  24. $k++;
  25. echo "You'll spent $k month before credit is become $credit \n\n\n";
  26.  
  27.  
  28.  
  29. break;
  30. }
  31.  
  32. $credit-=$payment;
  33. $k++;
  34.  
  35.  
  36. }
  37.  
  38. }
  39.  
  40. echo"Homocredit bank: \n";
  41. bankPayments(0.04,500,0);
  42. echo"Sofbank: \n";
  43. bankPayments(0.03,1000,0);
  44. echo"Strawberry bank: \n";
  45. bankPayments(0.02,0,7777);
  46.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Homocredit bank: 
Summary 56423.563121625 
You'll spent 12 month before credit is become 0 


Sofbank: 
Summary 61268.718210807 
You'll spent 13 month before credit is become 0 


Strawberry bank: 
Summary 53559.8738592 
You'll spent 11 month before credit is become 0