#!/usr/bin/perl -w use integer; my $max = 1000000; my @m = ("", "", 2 .. $max); for (my $n = 2; $n <= sqrt($max); $n++) { next unless $m[$n]; for (my $i = $n * 2; $i <= $max; $i += $n) { $m[$i] = ""; } } # print join("\n", grep($_, @m)), "\n";