Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions
Content added Content deleted
(→{{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: | Line 113: | ||
END; |
END; |
||
# print the numbers in decimal that are palendromic in bases 2, 4 and 16 # |
# 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 # |
|||
⚫ | |||
# 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 16 ) THEN |
||
IF PALINDROMIC ( n DIGITS 4 ) THEN |
IF PALINDROMIC ( n DIGITS 4 ) THEN |
||
Line 122: | Line 125: | ||
FI |
FI |
||
OD |
OD |
||
END |
|||
</syntaxhighlight> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |