Quad-power prime seeds: Difference between revisions
Content added Content deleted
(→{{header|ALGOL 68}}: should have mentioned the primes library...) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: extend out to 10 million) |
||
Line 203: | Line 203: | ||
<lang perl6>use Lingua::EN::Numbers; |
<lang perl6>use Lingua::EN::Numbers; |
||
my @qpps = lazy (1..*).hyper(: |
my @qpps = lazy (1..*).hyper(:5000batch).grep: -> \n { my \k = n + 1; (n+k).is-prime && (n²+k).is-prime && (n³+k).is-prime && (n⁴+k).is-prime } |
||
say "First fifty quad-power prime seeds:\n" ~ @qpps[^50].batch(10)».&comma».fmt("%7s").join: "\n"; |
say "First fifty quad-power prime seeds:\n" ~ @qpps[^50].batch(10)».&comma».fmt("%7s").join: "\n"; |
||
Line 209: | Line 209: | ||
say "\nFirst quad-power prime seed greater than:"; |
say "\nFirst quad-power prime seed greater than:"; |
||
for 1.. |
for 1..10 { |
||
my $threshold = Int(1e6 |
my $threshold = Int(1e6 × $_); |
||
my $key = @qpps.first: * > $threshold, :k; |
my $key = @qpps.first: * > $threshold, :k; |
||
say "{$threshold.&cardinal.fmt: '%13s'} is the {ordinal-digit $key + 1}: {@qpps[$key].&comma}"; |
say "{$threshold.&cardinal.fmt: '%13s'} is the {ordinal-digit $key + 1}: {@qpps[$key].&comma}"; |
||
Line 227: | Line 227: | ||
three million is the 319th: 3,005,316 |
three million is the 319th: 3,005,316 |
||
four million is the 383rd: 4,004,726 |
four million is the 383rd: 4,004,726 |
||
five million is the 452nd: 5,023,880 |
five million is the 452nd: 5,023,880 |
||
six million is the 514th: 6,000,554 |
|||
seven million is the 567th: 7,047,129 |
|||
eight million is the 601st: 8,005,710 |
|||
nine million is the 645th: 9,055,151 |
|||
ten million is the 701st: 10,023,600</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |