Partition an integer x into n primes: Difference between revisions

no edit summary
m (→‎{{header|Perl 6}}: bah. missed a character when cut & pasting)
No edit summary
Line 919:
-- "Partitioned 40355 with 3 primes: 3+139+40213"
</pre>
 
 
=={{header|Mathematica}}==
Just call the function F[X,N]
<lang Mathematica>F[x_, n_] :=
Print["Partitioned ", x, " with ", n, " primes: ",
StringRiffle[
ToString /@
Reverse[First@
Sort[Select[IntegerPartitions[x, {n}, Prime@Range@PrimePi@x],
Length@Union@# == n &], Last]], "+"]]
 
F[40355, 3]</lang>
 
 
{{out}}
<pre>
Partitioned 40355 with 3 primes: 5+7+40343
</pre>
 
 
=={{header|PARI/GP}}==