3v4l.org

run code in 300+ PHP versions simultaneously
<?php { // The n-th prime we're aiming for $n = 444; // The first prime is the only even one $primes = array(1 => 2); // Loop counters $c = 1; $p = 3; $cnt =0; while (true) { // Check if $p is prime $prime = true; $sqrt = sqrt($p); for ($i = 1; $i < $c && $primes[$i] <= $sqrt; $i++) { if ($p % $primes[$i] == 0) { $prime = false; break; } } // Record $p if prime if ($prime) { $primes[++$c] = $p; $hexchr = base_convert($p, 10, 16); if (strpos($hexchr,'beef') !== false) { $beefprime[++$cnt]=$p; echo "$p HEX IS $hexchr\n"; } if ($cnt == $n) { break; } } // Next $p to check $p += 2; } echo "444th prime number is $beefprime[$n]"; }

preferences:
53.62 ms | 402 KiB | 5 Q