Penta-power prime seeds: Difference between revisions
Content added Content deleted
(Add Factor) |
(lang -> syntaxhighlight) |
||
Line 29: | Line 29: | ||
NB: The source of the ALGOL 68-primes library is on a Rosetta Code code page linked from the above.<br> |
NB: The source of the ALGOL 68-primes library is on a Rosetta Code code page linked from the above.<br> |
||
Note that to run this with ALGOL 68G under Windows (and probably Linux) a large heap size must be specified on the command line, e.g. <code>-heap 1024M</code>. |
Note that to run this with ALGOL 68G under Windows (and probably Linux) a large heap size must be specified on the command line, e.g. <code>-heap 1024M</code>. |
||
< |
<syntaxhighlight lang=algol68>BEGIN # find some Penta power prime seeds, numbers n such that: # |
||
# n^p + n + 1 is prime for p = 0. 1, 2, 3, 4 # |
# n^p + n + 1 is prime for p = 0. 1, 2, 3, 4 # |
||
PR read "primes.incl.a68" PR # include prime utilities # |
PR read "primes.incl.a68" PR # include prime utilities # |
||
Line 104: | Line 104: | ||
) |
) |
||
OD |
OD |
||
END</ |
END</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 126: | Line 126: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2022-04-03}} |
{{works with|Factor|0.99 2022-04-03}} |
||
< |
<syntaxhighlight lang=factor>USING: grouping io kernel lists lists.lazy math math.functions |
||
math.primes prettyprint tools.memory.private ; |
math.primes prettyprint tools.memory.private ; |
||
Line 136: | Line 136: | ||
"First thirty penta-power prime seeds:" print |
"First thirty penta-power prime seeds:" print |
||
30 pentas ltake list>array 5 group simple-table.</ |
30 pentas ltake list>array 5 group simple-table.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 149: | Line 149: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang=Phix>(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">include</span> <span style="color: #004080;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
<span style="color: #008080;">include</span> <span style="color: #004080;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
||
Line 188: | Line 188: | ||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First penta-power prime seed greater than:\n%s"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">l</span><span style="color: #0000FF;">)</span> |
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First penta-power prime seed greater than:\n%s"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">l</span><span style="color: #0000FF;">)</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 210: | Line 210: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
< |
<syntaxhighlight lang=perl6>use Lingua::EN::Numbers; |
||
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 } |
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 } |
||
Line 222: | Line 222: | ||
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}"; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>First thirty penta-power prime seeds: |
<pre>First thirty penta-power prime seeds: |
||
Line 244: | Line 244: | ||
{{libheader|Wren-gmp}} |
{{libheader|Wren-gmp}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
< |
<syntaxhighlight lang=ecmascript>import "./gmp" for Mpz |
||
import "./fmt" for Fmt |
import "./fmt" for Fmt |
||
Line 283: | Line 283: | ||
} |
} |
||
n = n + 2 |
n = n + 2 |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |