<?php
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
function get_primes7($n) {
if ($n < 2) return array();
if ($n == 2) return array(2);
$s = range(3, $n, 2);
$mroot = sqrt($n);
$half = count($s);
$i = 0;
$m = 3;
while ($m <= $mroot) {
if ($s[$i]) {
$j = (int)(($m*$m - 3) / 2);
$s[$j] = 0;
while ($j < $half) {
$s[$j] = 0;
$j += $m;
}
}
$i = $i + 1;
$m = 2*$i + 3;
}
$res = array(2);
foreach ($s as $v) {
if ($v) {
$res[] = $v;
}
}
return $res;
}
$res = array();
for ($i = 1; $i <= 10; ++$i) {
$res = get_primes7(10000);
print "Found ".count($res)." prime numbers.\n";
}
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.32
- Parse error: syntax error, unexpected '<' in /in/FdRE8 on line 4
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '<' in /in/FdRE8 on line 4
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/FdRE8 on line 4
Process exited with code 255.
preferences:
217.86 ms | 1395 KiB | 123 Q