3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ini_set('memory_limit', -1); function find_primes($finish) { $number = 2; $range = range(2, $finish); $primes = array_combine($range, $range); while ($number * $number < $finish) { for ($i = $number; $i <= $finish; $i += $number) { if ($i == $number) { continue; } unset($primes[$i]); } $number = next($primes); } return $primes; } echo array_sum(find_primes(2000000));
Output for 5.3.19 - 5.6.21, 7.0.0 - 7.2.0
142913828922
Output for 5.6.28
Fatal error: Out of memory (allocated 259522560) (tried to allocate 32 bytes) in /in/2NP03 on line 9
Process exited with code 255.