Next highest int from digits: Difference between revisions

m
→‎{{header|REXX}}: added commas to the numbers in the output.
(→‎{{header|REXX}}: added the REXX computer programming language for this task.)
m (→‎{{header|REXX}}: added commas to the numbers in the output.)
Line 282:
parse arg n /*obtain optional arguments from the CL*/
if n='' | n="," then n= 0 9 12 21 12453 738440 45072010 95322020 /*use the defaults? */
w= length( commas(word(n, words(n) ) ) ) /*maxmaximum width number (with commas). */
 
do j=1 for words(n); y= word(n, j) /*process each of the supplied numbers.*/
Line 295:
 
if #>lim then #= 0 /*if # > lim, then there is no valid #*/
say 'for ' right(commas(y), w) ", ─── the next highest integer is: " right(commas(#), w)
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg _; do c=length(_)-3 to 1 by -3; _=insert(',', _, c); end; return _
/*──────────────────────────────────────────────────────────────────────────────────────*/
mask: parse arg z, $; @.= 0 /* [↓] build an unsorted digit mask. */
Line 306 ⟶ 308:
{{out|output|text=  when using the default inputs:}}
<pre>
for 0, ─── the next highest integer is: 0
for 9, ─── the next highest integer is: 0
for 12, ─── the next highest integer is: 21
for 21, ─── the next highest integer is: 0
for 12453 12,453 ─── the next highest integer is: 12534 12,534
for 738440 738,440 ─── the next highest integer is: 740348 740,348
for 4507201045,072,010 ─── the next highest integer is: 4507210045,072,100
for 9532202095,322,020 ─── the next highest integer is: 9532220095,322,200
</pre>