Special divisors: Difference between revisions

m
→‎{{header|REXX}}: change output title, simplified the code, changed some comments.
m (→‎{{header|REXX}}: used better variable names, changed/add whitespace and comments.)
m (→‎{{header|REXX}}: change output title, simplified the code, changed some comments.)
Line 343:
=={{header|REXX}}==
<lang rexx>/*REXX program finds special divisors: numbers N such that reverse(D) divides ··· */
/*─────────────────────────────────────────────────────────────────────── reverse(N) for all divisors D of N, where N < 200. */
parse arg hi cols . /*obtain optional argument from the CL.*/
if hi=='' | hi=="," then hi= 200 /* " " " " " " */
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
w= 10 /*width of a number in any column. */
title= ' special divisors N that reverse(D) divides reverse(N) for all divisiors' ,
'for all divisors D of N, where N < ' commas(hi)
if cols>0 then say ' index │'center(title, 1 + cols*(w+1) )
if cols>0 then say '───────┼'center("" , 1 + cols*(w+1), '─')
Line 356:
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*/
if j//k==0 then if r//reverse(k)\==0 then nop iterate J /*Is Not OK? keepSkip*/
else iterate j /*Not OK? Skip*/
end /*m*/
found= found + 1 /*bump the number of special divisors. */
if cols<0 then iterate /*Build the list (to be shown later)? */
c= commas(j) /*maybe add commas to the number. */
Line 377 ⟶ 376:
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
index │ special divisors N that reverse(D) divides reverse(N) for all divisorsdivisiors D of N, where N < 200
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 1 2 3 4 5 6 7 8 9 11
Line 389 ⟶ 388:
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
Found 72 special divisors N that reverse(D) divides reverse(N) for all divisorsdivisiors D of N, where N < 200
</pre>