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