Anonymous user
Special divisors: Difference between revisions
m
→{{header|REXX}}: used better variable names, changed/add whitespace and comments.
m (added whitespace and highlihting.) |
m (→{{header|REXX}}: used better variable names, changed/add whitespace and comments.) |
||
Line 342:
=={{header|REXX}}==
<lang rexx>/*REXX program finds special divisors: numbers N such that reverse(D) divides
/*───────────────────────────────────────────── reverse(N) for all divisors D of N. */
parse arg hi cols . /*obtain optional argument from the CL.*/
Line 348:
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
w= 10 /*width of a number in any column. */
'for all divisors D of N, where N < ' commas(hi)
if cols>0 then say ' index │'center(
if cols>0 then say '───────┼'center("" , 1 + cols*(w+1), '─')
$= /*a list of numbers
do j=1 for hi-1; r= reverse(j) /*search for special divisors. */
do k=2 to j%2 /*skip the first divisor (unity) & last*/
Line 359:
else iterate j /*Not OK? Skip*/
end /*m*/
if cols
c= commas(j) /*maybe add commas to the number. */
$= $ right(c, max(w, length(c) ) ) /*add a
if
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
idx= idx + cols /*bump the index count for the output*/
Line 371:
if cols>0 then say '───────┴'center("" , 1 + cols*(w+1), '─')
say
say 'Found ' commas(
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
|