Smallest numbers: Difference between revisions

m
→‎{{header|REXX}}: code was added to support the displaying of unique numbers found.
m (→‎{{header|REXX}}: simplified the code.)
m (→‎{{header|REXX}}: code was added to support the displaying of unique numbers found.)
Line 682:
 
=={{header|REXX}}==
Code was added to display the count of unique numbers found.
<lang rexx>/*REXX pgm finds the smallest positive integer K where K**K contains N, N < 51 */
numeric digits 200 /*ensure enough decimal digs for k**k */
Line 691 ⟶ 692:
say ' N │'center(title, 5 + cols*(w+1) ) /*display the title of the output. */
say '─────┼'center("" , 5 + cols*(w+1), '─') /* " " separator " " " */
$u= 0; idx= 0 !.= . /*definenumber of $unique #'s output listfound; index to 0.semaphore*/
$=; idx= 0 /*define $ output list; index to 0.*/
do j=0 for hi /*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*/
if !.k==. then do; u= u+1; !.k=; end /*Is unique? Then bump unique counter.*/
c= commas(k) /*maybe add commas to the powe of six. */
$= $ right(c, max(w, length(c) ) ) /*add a K (power) ──► list, allow big#*/
Line 704 ⟶ 707:
if $\=='' then say center(idx, 5)"│"substr($,2) /*possible display any residual output.*/
say '─────┴'center("" , 5 + cols*(w+1), '─') /* " " separator " " " */
say
say commas(u) ' unique numbers found.'
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 718 ⟶ 723:
50 │ 23
─────┴───────────────────────────────────────────────────────────────────────────
 
23 unique numbers found.
</pre>