fork(1) download
  1. <?php
  2. // This is my first PHP lab01
  3.  
  4. $n = 0;
  5. $i = 0;
  6. $s = 0;
  7.  
  8.  
  9. echo "Please enter value for N\n";
  10. $n = (int)readline();
  11. $s = 0;
  12.  
  13.  
  14. for ($i = 1; $i <= $n; $i+=1)
  15. {
  16. if ($i % 2 == 0)
  17. {
  18. $s=$s+$i;
  19. echo ("Current value i=" . $i . " S=" . $s);
  20. echo ("\n");
  21. }
  22. }
  23.  
  24. echo ("Final result suma is S=" . $s);
  25. ?>
Success #stdin #stdout 0.02s 26508KB
stdin
4
stdout
Please enter value for N
Current value i=2 S=2
Current value i=4 S=6
Final result suma is S=6