Distinct power numbers: Difference between revisions

m
→‎{{header|REXX}}: simplified the code.
(Added Go)
m (→‎{{header|REXX}}: simplified the code.)
Line 59:
=={{header|REXX}}==
<lang rexx>/*REXX pgm finds and displays distinct power integers: a^b, where a and b are 2≤both≤5*/
parse arg n lo hi cols . /*obtain optional argumentarguments from the CL.*/
if nlo=='' | nlo=="," then nlo= 15 2 /*Not specified? Then use the default.*/
if lo=='' | lo=="," then lo= 2 /* " " " " " " */
if hi=='' | hi=="," then hi= 5 /* " " " " " " */
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
Line 77 ⟶ 76:
found= 0; idx= 1 /*initialize # distinct power integers.*/
$= /*a list of distinct power integers. */
do j=0 for mx+1; untilif found@.j==n . then iterate /*searchNumber numbernot rangefound orin until1st NDO found.loop? Skip*/
if @.j==. then iterate /*this number "found" in 1st DO loop?*/
found= found + 1; c= commas(j) /*maybe add commas to the number. */
$= $ right(c, max(w, length(c) ) ) /*add a distinct power number ──► list.*/