This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A373941 #29 Jun 28 2024 11:46:57 %S A373941 0,1,3,7,15,21,31,45,63,73,127,153,255,273,341,443,511,561,693,891, %T A373941 1023,1057,1453,1651,2047,2145,2925,3315,4095,4161,4681,5461,5981, %U A373941 6371,6891,7671,8191,8385,9417,10965,11997,12771,13803,15351,16383,16513,19609,21157 %N A373941 Numbers whose base-2 representation is a "nested" palindrome. %C A373941 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. %H A373941 Michael S. Branicky, <a href="/A373941/b373941.txt">Table of n, a(n) for n = 1..10000</a> %e A373941 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. %e A373941 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. %o A373941 (Python) %o A373941 from sympy import isprime %o A373941 from itertools import count, islice, product %o A373941 def pals(d, base=10): # returns a string %o A373941 digits = "".join(str(i) for i in range(base)) %o A373941 for p in product(digits, repeat=d//2): %o A373941 if d//2 > 0 and p[0] == "0": continue %o A373941 left = "".join(p); right = left[::-1] %o A373941 for mid in [[""], digits][d%2]: %o A373941 yield left + mid + right %o A373941 def nbp_gen(): # generator of nested binary palindromes (as strings) %o A373941 for d in count(2): %o A373941 yield from (p+p[-1-d%2::-1] for p in pals((d+1)//2, base=2)) %o A373941 def agen(): # generator of terms %o A373941 yield from [0, 1] %o A373941 yield from (int(nbp, 2) for nbp in nbp_gen() if nbp[0] != "0") %o A373941 print(list(islice(agen(), 46))) %o A373941 (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 %Y A373941 Base-2 analog of A344550. %Y A373941 Cf. A373581 (prime terms). %K A373941 nonn,base %O A373941 1,3 %A A373941 _Michael S. Branicky_, Jun 23 2024