Sexy primes: Difference between revisions
→{{header|Perl 6}}: Better categorize logic, faster filtering. Also move alert box to last unmodified entry
(Added Kotlin) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Better categorize logic, faster filtering. Also move alert box to last unmodified entry) |
||
Line 1:
{{draft task}}
{{Wikipedia|Sexy_prime}}
{{alertbox|pink|Note: the task requirements have changed for reasons found on the discussion page. Please update tasks to meet the updated requirements.}} ▼
Line 578 ⟶ 575:
my $max = 1_000_035;
my
my $
my $primes = @primes.categorize: { .&sexy }
say "Total primes less than {comma $max}: ", comma +
for <pair 2 triplet 3 quadruplet 4 quintuplet 5> -> $sexy, $cnt {
say "Number of sexy prime {$sexy}s less than {comma $max}: ", comma +$primes{$sexy};
say " Last 5 sexy prime {$sexy}s less than {comma $max}: ",
join ' ', $primes{$sexy}
{ "({ $_ «+« (0,6 … 24)[^$cnt] })" }
say '';
Line 593 ⟶ 591:
say "Number of unsexy primes less than {comma $max}: ", comma +$primes<unsexy>;
say " Last 10 unsexy primes less than {comma $max}: ", $primes<unsexy>
sub sexy ($i) {
take
}
}
Line 625 ⟶ 623:
=={{header|Python}}==
▲{{alertbox|pink|Note: the task requirements have changed for reasons found on the discussion page. Please update
<lang python>LIMIT = 1_000_000
def primes2(limit=LIMIT):
|