Penta-power prime seeds: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: only check odds as noted on talk page. less than a 5% speed up but worth it) |
|||
Line 188: | Line 188: | ||
<lang perl6>use Lingua::EN::Numbers; |
<lang perl6>use Lingua::EN::Numbers; |
||
my @ppps = lazy ( |
my @ppps = lazy (^∞).hyper(:5000batch).map(* × 2 + 1).grep: -> \n { my \k = n + 1; (1+k).is-prime && (n+k).is-prime && (n²+k).is-prime && (n³+k).is-prime && (n⁴+k).is-prime } |
||
say "First thirty penta-power prime seeds:\n" ~ @ppps[^30].batch(10)».&comma».fmt("%9s").join: "\n"; |
say "First thirty penta-power prime seeds:\n" ~ @ppps[^30].batch(10)».&comma».fmt("%9s").join: "\n"; |
||
Line 195: | Line 195: | ||
for 1..10 { |
for 1..10 { |
||
my $threshold = Int(1e6 |
my $threshold = Int(1e6 × $_); |
||
my $key = @ppps.first: * > $threshold, :k; |
my $key = @ppps.first: * > $threshold, :k; |
||
say "{$threshold.&cardinal.fmt: '%13s'} is the {ordinal-digit $key + 1}: {@ppps[$key].&comma}"; |
say "{$threshold.&cardinal.fmt: '%13s'} is the {ordinal-digit $key + 1}: {@ppps[$key].&comma}"; |