Smallest numbers: Difference between revisions

m
→‎{{header|REXX}}: simplified the code.
m (→‎{{header|REXX}}: simplified the code.)
Line 688:
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
w= 6 /*width of a number in any column. */
@spiKKtitle=' smallest positive integer K where K**K contains N, 0 ≤ N < ' commas(hi)
say ' N │'center(@spiKKtitle, 5 + cols*(w+1) ) /*display the title of the output. */
say '─────┼'center("" , 5 + cols*(w+1), '─') /* " " separator " " " */
$=; idx= 0 /*define $ output list; index to 0.*/
do j=0 for hi; n= j + 1 /*look for a power of 6 that contains N*/
do k=1 until pos(j, k**k)>0 /*calculate a bunch of powers (K**K). */
end /*k*/
c= commas(k) /*maybe add commas to the powe of six. */
$= $ right(c, max(w, length(c) ) ) /*add a K (power) ──► list, allow big#*/
if n(j+1)//cols\==0 then iterate /*have we populated a line of output? */
say center(idx, 5)'│'substr($, 2); $= /*display what we have so far (cols). */
idx= idx + cols /*bump the index count for the output*/
Line 703:
 
if $\=='' then say center(idx, 5)"│"substr($,2) /*possible display any residual output.*/
say '─────┴'center("" , 5 + cols*(w+1), '─') /* " " separator " " " */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/