Anonymous user
Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions
Numbers in base 10 that are palindromic in bases 2, 4, and 16 (view source)
Revision as of 20:24, 24 June 2021
, 2 years ago→{{header|REXX}}: updated with an optimized version that skips all of the even integers (except zero).
(→{{header|REXX}}: added the computer programming language REXX.) |
(→{{header|REXX}}: updated with an optimized version that skips all of the even integers (except zero).) |
||
Line 158:
The use of REXX's BIFs to convert decimal numbers to binary and hexadecimal were used (instead of the '''base'''
<br>function) because they are much faster).
This REXX version takes advantage that no even integers need be tested (except for the single exception: zero).
<lang rexx>/*REXX pgm finds non─neg integers that are palindromes in base 2, 4, and 16, where N<25k*/
numeric digits 100 /*ensure enough dec. digs for large #'s*/
Line 168 ⟶ 170:
say ' index │'center(title, 1 + cols*(w+1) ) /*display the title for the output. */
say '───────┼'center("" , 1 + cols*(w+1), '─') /* " a sep " " " */
idx= 1
idx= idx + cols /*bump the index count for the output*/
end /*j*/
if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible display residual output.*/
|