3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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 git.master, git.master_jit, rfc.property-hooks
Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers. Found 1229 prime numbers.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.45 ms | 401 KiB | 8 Q