OFFSET
1,3
COMMENTS
The definition of "nested" palindrome per A344550 is used: both the right and left halves of the base-2 representation of each term are themselves palindromes. "Half" means ceiling(m/2) for an m-bit term.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
45 = 101101_2 is a term, since its base-2 representation is a palindrome, and its right half and left half in base-2 are each the palindrome 101.
73 = 1001001_2 is a term, since its base-2 representation is a palindrome, and its right half and left half (both including the center digit) in base-2 are each the palindrome 1001.
PROG
(Python)
from sympy import isprime
from itertools import count, islice, product
def pals(d, base=10): # returns a string
digits = "".join(str(i) for i in range(base))
for p in product(digits, repeat=d//2):
if d//2 > 0 and p[0] == "0": continue
left = "".join(p); right = left[::-1]
for mid in [[""], digits][d%2]:
yield left + mid + right
def nbp_gen(): # generator of nested binary palindromes (as strings)
for d in count(2):
yield from (p+p[-1-d%2::-1] for p in pals((d+1)//2, base=2))
def agen(): # generator of terms
yield from [0, 1]
yield from (int(nbp, 2) for nbp in nbp_gen() if nbp[0] != "0")
print(list(islice(agen(), 46)))
(PARI) isok(k) = my(b=binary(k), b1=Vec(b, ceil(#b/2)), b2=Vec(Vecrev(b), ceil(#b/2))); (Vecrev(b) == b) && (Vecrev(b1) == b1) && (Vecrev(b2) == b2); \\ Michel Marcus, Jun 26 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Jun 23 2024
STATUS
approved