Skip to content

Instantly share code, notes, and snippets.

View mmcclimon's full-sized avatar

Michael McClimon mmcclimon

View GitHub Profile
@mmcclimon
mmcclimon / primeSieve.pl
Created August 9, 2012 13:59
A Perl implementation of the Sieve of Eratosthenes to find primes
sub sieve {
my $limit = shift || 1000;
my @list = map {$_ = 1} 0..$limit;
for my $i (2..sqrt($limit)) {
if ($list[$i]) {
for (my $j = $i**2; $j < @list; $j += $i) {
$list[$j] = 0;
}
}
}