Partition function P: Difference between revisions

→‎{{header|Raku}}: Add a Raku example
(→‎{{header|Python}}: Mathloger video prime generator)
(→‎{{header|Raku}}: Add a Raku example)
Line 305:
{{Out}}
<pre>Primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]</pre>
 
=={{header|Raku}}==
{{works with|Rakudo|2020.09}}
Not the fastest, but it gets the job done.
<lang perl6>my @P = 1, { p(++$) } … *;
my @i = lazy [\+] flat 1, ( (1 .. *) Z (1 .. *).map: * × 2 + 1 );
sub p ($n) { sum @P[$n X- @i[^(@i.first: * > $n, :k)]] Z× (flat (1, 1, -1, -1) xx *) }
 
say @P[6666];</lang>
{{out}}
<pre>193655306161707661080005073394486091998480950338405932486880600467114423441282418165863</pre>
 
=={{header|REXX}}==
10,333

edits