cp's OEIS Frontend

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.

Showing 1-3 of 3 results.

A373581 Prime numbers whose base-2 representation is a "nested" palindrome.

Original entry on oeis.org

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
Offset: 1

Views

Author

James S. DeArmon, Jun 10 2024

Keywords

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).)

Examples

			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".
		

Crossrefs

Subsequence of A016041.
Primes in A373941.
Cf. A344550.

Programs

  • 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.

A373941 Numbers whose base-2 representation is a "nested" palindrome.

Original entry on oeis.org

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

Views

Author

Michael S. Branicky, Jun 23 2024

Keywords

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.

Examples

			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.
		

Crossrefs

Base-2 analog of A344550.
Cf. A373581 (prime terms).

Programs

  • 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
  • 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)))
    

A368020 Palindromes which are a concatenation of three palindromes, each of which has at least 2 digits.

Original entry on oeis.org

110011, 111111, 112211, 113311, 114411, 115511, 116611, 117711, 118811, 119911, 220022, 221122, 222222, 223322, 224422, 225522, 226622, 227722, 228822, 229922, 330033, 331133, 332233, 333333, 334433, 335533, 336633, 337733, 338833, 339933, 440044, 441144, 442244
Offset: 1

Views

Author

James S. DeArmon, Dec 23 2023

Keywords

Comments

Equivalently, these are palindromes which have a palindromic prefix of length at least 2 and no more than 1 less than half the total length. For example, 7 digit terms have the form (aa)(bcb)(aa) and 8 digit terms are of the form (aa)(bccb)(aa) or (aba)(cc)(aba).

Examples

			110011 is a term since it is a palindrome, and consists of 3 palindromes: (11)(00)(11).
9999999 is a term and its constituent 3 palindromes can be listed in three ways: (99)(999)(99), (999)(99)(99), and (99)(99)(999).
		

Crossrefs

Cf. A002113 (palindromes), A344550.

Programs

  • Python
    # see Link
    
  • Python
    from itertools import count, islice, product
    def pals(d=2): # generator of palindromes with d >=2 digits as strings
        yield from (f+(s:="".join(r))+m+s[::-1]+f for f in "123456789" for r in product("0123456789", repeat=d//2-1) for m in [[""], "0123456789"][d%2])
    def agen(): # generator of terms
        yield from (int("".join(p)) for d in count(6) for p in pals(d) if any((s:=p[:i])==s[::-1] for i in range(2, d//2)))
    print(list(islice(agen(), 33))) # Michael S. Branicky, Jan 23 2024
Showing 1-3 of 3 results.