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 18:09, 11 November 2023
, 6 months ago→{{header|ALGOL 68}}: Tweak by using the REXX solution observation that other than 0 the numbers must be odd
(→{{header|RPL}}: faster approach) |
(→{{header|ALGOL 68}}: Tweak by using the REXX solution observation that other than 0 the numbers must be odd) |
||
Line 113:
END;
# print the numbers in decimal that are palendromic in bases 2, 4 and 16 #
# as noted by the REXX sample, even numbers ( other than 0 ) aren't #
FOR n FROM 0 TO max number DO▼
# applicable as even numbers end in 0 in base 2 so can't be palendromic #
print( ( " 0" ) ); # clearly, 0 is palendromic in all bases #
IF PALINDROMIC ( n DIGITS 16 ) THEN
IF PALINDROMIC ( n DIGITS 4 ) THEN
Line 122 ⟶ 125:
FI
OD
END
{{out}}
<pre>
|