3v4l.org

run code in 300+ PHP versions simultaneously
<?php $primes = array(); $found = 0; for ($x = 2; $x <= 100000; $x++) { $xIsPrime = TRUE; $sqrtX = sqrt($x); foreach ($primes as $prime) if ($prime > $sqrtX || ((!($x % $prime)) && (!$xIsPrime = FALSE))) break; if ($xIsPrime) $found++; } echo $found;

preferences:
37.66 ms | 402 KiB | 5 Q