Strong and weak primes: Difference between revisions
m
→{{header|Perl 6}}: Style tweaks, DRY
m (→{{header|Pascal}}: changed indifferent into balanced) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Style tweaks, DRY) |
||
Line 460:
my @primes = $sieve.primes(10_000_019);
my (@weak, @balanced, @strong);
for 1 ..^ @primes - 1 -> $p {
given (@primes[$p - 1] + @primes[$p + 1]) / 2 {
when * > @primes[$p] { @weak.push: @primes[$p] }
when * < @primes[$p] { @strong.push: @primes[$p] }
default { @balanced.push: @primes[$p] }
}
}
for @strong, 'strong', 36
@weak, 'weak', 37
@balanced, 'balanced', 28
-> @pr, $type, $d
say "\nFirst $d $type primes:\n", @pr[^$d]».,
say "Count of $type primes <= {comma
say "Count of $type primes <= {comma
}</lang>
{{out}}
|