login
A373941
Numbers whose base-2 representation is a "nested" palindrome.
2
0, 1, 3, 7, 15, 21, 31, 45, 63, 73, 127, 153, 255, 273, 341, 443, 511, 561, 693, 891, 1023, 1057, 1453, 1651, 2047, 2145, 2925, 3315, 4095, 4161, 4681, 5461, 5981, 6371, 6891, 7671, 8191, 8385, 9417, 10965, 11997, 12771, 13803, 15351, 16383, 16513, 19609, 21157
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
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
Base-2 analog of A344550.
Cf. A373581 (prime terms).
Sequence in context: A182247 A121712 A175544 * A139208 A324727 A320026
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Jun 23 2024
STATUS
approved