Fermat pseudoprimes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (better title) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: better parenthesis placement) |
||
Line 54: | Line 54: | ||
my @pseudo = lazy (1..*).hyper.grep: { !.is-prime && (exp($_ - 1, $base) % $_ == 1) } |
my @pseudo = lazy (1..*).hyper.grep: { !.is-prime && (exp($_ - 1, $base) % $_ == 1) } |
||
my $threshold = 50000; |
my $threshold = 50000; |
||
say $base.fmt("Base %2d - Up to $threshold: " ~ (+@pseudo.&upto: $threshold).fmt('%5d') |
say $base.fmt("Base %2d - Up to $threshold: ") ~ (+@pseudo.&upto: $threshold).fmt('%5d') |
||
~ " First 20: " |
~ " First 20: " ~ @pseudo[^20].gist |
||
}</lang> |
}</lang> |
||
<pre>Base 1 - Up to 50000: 44866 First 20: (4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 32) |
<pre>Base 1 - Up to 50000: 44866 First 20: (4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 32) |