Chernick's Carmichael numbers: Difference between revisions
m
→{{header|Perl 6}}: Simplify, tidy
(→{{header|Go}}: Added much faster version to deal with optional requirement.) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Simplify, tidy) |
||
Line 439:
use ntheory:from<Perl5> <:all>;
sub chernick
6*$m + 1, 12*$m + 1, |((1 .. $n-2).map: { (1 +< $_) * 9*$m + 1 } )
}
Line 445:
sub chernick-carmichael-number ($n) {
my $multiplier = 1 +< (($n-4) max 0);
my $iterator = $n < 5 ?? (1 .. *) !! (1 .. *).map: * * 5;
}
▲ [&&] chernick-carmichael-factors($n, $m * $multiplier).map: { is_prime($_) #`[ .is-prime ] }
}
for 3 .. 9 -> $n {
my
say "U($n, $m): {[*] @f} = {@f.join(' ⨉ ')}";
}</lang>
{{out}}
<pre>
=={{header|Sidef}}==
|