Skip to content

anonymous /euler47.p6

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
Something went wrong with that request. Please try again.