Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2012 04:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/4200603 to your computer and use it in GitHub Desktop.
Perl 6 Project Euler 47
constant $N = 3;
my @primes;
my $in-a-row = 0;
for 2 .. * {
my $count = 0;
for @primes -> $prime {
if ($prime.key == $_) {
$prime.key += $prime.value;
++$count;
}
}
if ($count >= $N) {
++$in-a-row;
}
else {
if ($count == 0) {
@primes.push($_*2 => $_);
}
$in-a-row = 0;
}
if ($in-a-row == $N) {
say $_ - $N + 1;
last;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment