login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A340559
Numbers that are palindromic in base 2 and base 16.
1
0, 1, 3, 5, 7, 9, 15, 17, 51, 85, 119, 153, 255, 257, 273, 771, 819, 1285, 1317, 1365, 1397, 1799, 1831, 1879, 1911, 2313, 2409, 2457, 2553, 3855, 3951, 3999, 4095, 4097, 4369, 12291, 13107, 20485, 21029, 21845, 22389, 28679, 29223, 30039, 30583, 36873, 38505
OFFSET
1,3
MATHEMATICA
Select[Range[0, 10^5], PalindromeQ @ IntegerDigits[#, 2] && PalindromeQ @ IntegerDigits[#, 16] &] (* Amiram Eldar, Jan 11 2021 *)
PROG
(Python)
def palindrome(x):
res = str(x) == str(x)[::-1]
return res
def dec_to_bin(x):
return int(bin(x)[2:])
def dec_to_hex(x):
return (hex(x)[2:])
for x in range (1, 10000):
if palindrome(dec_to_hex(x)) & palindrome(dec_to_bin(x)) == True:
print(x)
(BASIC:- MM Basic, a modern QBASIC variant, https://www.mmbasic.com/)
Function reverse(in_string$) As string
Local r$
Local i
For i = Len(in_string$) To 1 Step -1
b$=Mid$(in_string$, i, 1)
r$=r$+b$
Next i
reverse=r$
End Function
For i = 1 To 10000
If Bin$(i) = reverse(Bin$(i)) Then
If Hex$(i) = reverse(Hex$(i)) Then
Print i, Bin$(i), Hex$(i)
EndIf
EndIf
Next i
(PARI) ispal(m, b) = my(d=digits(m, b)); d == Vecrev(d);
isok(m) = ispal(m, 2) && ispal(m, 16); \\ Michel Marcus, Jan 20 2021
CROSSREFS
Intersection of A006995 and A029730.
Sequence in context: A265852 A335132 A343727 * A073674 A084722 A083566
KEYWORD
nonn,base
AUTHOR
Glen Gilchrist, Jan 11 2021
STATUS
approved