login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A373581 Prime numbers whose base-2 representation is a "nested" palindrome. 2
3, 7, 31, 73, 127, 443, 1453, 5981, 8191, 19609, 21157, 28123, 29671, 83269, 131071, 262657, 287281, 324217, 354997, 367309, 431947, 456571, 462727, 499663, 524287, 1348901, 1488301, 1715851, 1875751, 5548693, 6298627, 7331323, 7355911, 8093551, 8191903 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
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 a m-bit term. (By contrast, A240601 uses floor(m/2).)
LINKS
EXAMPLE
Terms 1,2,and 3 are 3,7,31, with respective base-2 valuations of 11, 111, 11111. The fourth term, 73, is the smallest term containing zeros in the base-2 representation: 1001001. Note the middle bit is shared by both halves; the nested palindrome is "1001".
PROG
(Python)
import sympy
def ispal(n):
return str(n) == str(n)[::-1]
def isodd(n): return n%2
outVec = []
for n in range(9999999):
if not sympy.isprime(n): continue
binStr = (bin(n))[2:]
if not ispal(binStr): continue
lenB = len(binStr)
halfB = int(lenB/2)
if isodd(lenB): halfB += 1
if not ispal(binStr[:halfB]): continue
print(n, binStr)
outVec.append(n)
print(outVec)
(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)
yield '0'
for d in count(1):
yield from (p+p[-1-d%2::-1] for p in pals((d+1)//2, base=2))
def agen(): # generator of terms
yield from filter(isprime, (int(nbp, 2) for nbp in nbp_gen()))
print(list(islice(agen(), 36))) # Michael S. Branicky, Jun 12 2024
(Common LISP) ; See LINKS section.
CROSSREFS
Subsequence of A016041.
Primes in A373941.
Cf. A344550.
Sequence in context: A091383 A166501 A261862 * A226216 A244114 A072881
KEYWORD
nonn,base
AUTHOR
James S. DeArmon, Jun 10 2024
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 14 09:16 EDT 2024. Contains 375159 sequences. (Running on oeis4.)