fork download
  1. <?php
  2. $start=$_GET["num"];
  3. echo "Prime Numbers between 0 to ".$start.": ";
  4. function primefun($n){
  5. $count = 1;
  6. for($i = 2; $i<=$n/2;$i++){
  7. if($n % $i == 0){
  8. $count =0;
  9. }
  10. }
  11. return $count;
  12. }
  13. for ($x = 2; $x <= $start; $x++) {
  14. $r=primefun($x);
  15. if($r== 1){
  16. echo "$x<br>";
  17. }
  18. }
  19. ?>
Success #stdin #stdout #stderr 0.02s 26044KB
stdin
10
stdout
Prime Numbers between 0 to : 
stderr
PHP Notice:  Undefined index: num in /home/GdkJXn/prog.php on line 2