3v4l.org

run code in 300+ PHP versions simultaneously
<?php $n = 80000; $start = microtime(true); $arr = array(); if ($n >= 2) $arr[] = 2; for ($i = 3; $i<=$n; $i+=2) { $arr[] = $i; } foreach ($arr as $key=>$row) { foreach($arr as $key2=>$row2) { if ($key2 > $key && ($row2 % $row) === 0) { unset($arr[$key2]); } } } $arr = array_values($arr); echo '<pre>'; echo array_sum($arr), PHP_EOL; echo (microtime(true)-$start);
Output for 5.3.7 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0

Process exited with code 137.

preferences:
96.05 ms | 402 KiB | 115 Q