login
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)
(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