Partition function P: Difference between revisions

m
→‎{{header|Raku}}: minor style tweaks, remove some unnecessary reification
m (syntax highlighting fixup automation)
m (→‎{{header|Raku}}: minor style tweaks, remove some unnecessary reification)
Line 1,483:
Not the fastest, but it gets the job done.
<syntaxhighlight lang="raku" line>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 *) }
 
put @P[^26];
10,333

edits