Partition an integer x into n primes: Difference between revisions
Partition an integer x into n primes (view source)
Revision as of 16:07, 16 April 2020
, 4 years ago→{{header|Phix}}: is_prime() now builtin
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
m (→{{header|Phix}}: is_prime() now builtin) |
||
Line 1,181:
=={{header|Phix}}==
<lang Phix>function partition(integer v, n, idx=0)
if n=1 then
Line 1,189 ⟶ 1,188:
while 1 do
idx += 1
if np>=floor(v/2) then exit end if
res = partition(v-np, n-1, idx)
Line 1,215 ⟶ 1,211:
object res = partition(v,n)
res = iff(res=0?"not possible":sprint(res))
printf(1,"
end for</lang>
{{out}}
<pre>
</pre>
|