Anonymous user
Partition an integer x into n primes: Difference between revisions
m
→{{header|REXX}}: added usage comments to the REXX section header, changed REXX program to use a more idiomatic function name.
m (combined two bullets.) |
m (→{{header|REXX}}: added usage comments to the REXX section header, changed REXX program to use a more idiomatic function name.) |
||
Line 35:
=={{header|REXX}}==
Usage note: entering ranges of '''X''' and '''N''' numbers (arguments) from the command line:
::::: <big> '''X-Y''' '''N-M''' <b> ∙∙∙ </b> </big>
which means: partition all integers (inclusive) from '''X''' ──► '''Y''' with '''N''' ──► '''M''' primes.
<br>The ''to'' number ('''Y''' or '''M''') can be omitted.
<lang rexx>/*REXX program partitions integer(s) (greater than unity) into N primes. */
parse arg what /*obtain an optional list from the C.L.*/
Line 64 ⟶ 69:
i.z=i.z+1; _=i.z; p.z=@._; return 0
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
part: i.=0; do j=1 for q; call getP j; end /*j*/
Line 79 ⟶ 84:
if $ <g then do; call getP q; iterate; end
end /*!*/ /* [↑] Is sum too low? Bump a prime.*/
say 'partitioned' center(g,9) "into" center(q, 5)
return</lang>
{{out|output|text= when using the input of: <tt> 99809 1 18 2 19 3 20 4 2017 24 22699 1-4 40355 </tt>
|