Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions

→‎{{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 #
FOR n FROMBY 02 TO max number DO
IF PALINDROMIC ( n DIGITS 16 ) THEN
IF PALINDROMIC ( n DIGITS 4 ) THEN
Line 122 ⟶ 125:
FI
OD
END
END</syntaxhighlight>
{{out}}
<pre>
3,028

edits