Anonymous user
Partition an integer x into n primes: Difference between revisions
Partition an integer x into n primes (view source)
Revision as of 19:15, 30 November 2018
, 5 years agono edit summary
Thundergnat (talk | contribs) 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}}==
|