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-4 of 4 results.

A243035 Number of entries of length n in A240601.

Original entry on oeis.org

10, 9, 90, 9, 90, 90, 900, 9, 90, 90, 900, 90, 900, 900, 9000, 9, 90, 90, 900, 90, 900, 900, 9000, 90, 900, 900, 9000, 900, 9000, 9000, 90000, 9, 90, 90, 900, 90, 900, 900, 9000, 90, 900, 900, 9000, 900, 9000, 9000, 90000, 90, 900, 900, 9000, 900, 9000, 9000
Offset: 1

Views

Author

Lior Manor, May 29 2014

Keywords

Comments

For n>0, a(2^n) = 9.
For any base b, a(1) = b, a(2) = b-1, a(3) = b*(b-1), for m>1, a(2m) = a(m), a(2m+1) = b*a(m).
For any base b, a(n) = (b-1)*b^(A000120(n)-1).

Crossrefs

Formula

a(1) = 10, a(2) = 9, a(3) = 90, For m>1, a(2m) = a(m), a(2m+1) = 10*a(m).
a(n) = 9*10^(A000120(n)-1).

A240602 Recursive palindromes in base 2: palindromes n where each half of the digits of n is also a recursive palindrome.

Original entry on oeis.org

0, 1, 11, 101, 111, 1111, 11011, 11111, 101101, 111111, 1010101, 1011101, 1110111, 1111111, 11111111, 111101111, 111111111, 1101111011, 1111111111, 11011011011, 11011111011, 11111011111, 11111111111, 101101101101, 111111111111, 1011010101101, 1011011101101, 1111110111111, 1111111111111
Offset: 1

Views

Author

Lior Manor, Apr 13 2014

Keywords

Comments

A number n with m digits in base 2 is a member of a(n) if n is a palindrome, and the first floor(m/2) digits of n is already a previous term of a(n). Fast generation of new terms with 2m digits can be done by concatenating the previous terms with m digits twice. Fast generation of new terms with 2m+1 digits can be done by concatenating the previous terms with m digits twice with any single digit in the middle. The smallest palindrome which is not a member of a(n) is 1001.

Examples

			11011 is in the sequence since it is a palindrome of 5 digits, and the first floor(5/2) digits of it, 11, is also a term. 1001 and 10001 are not in a(n) since 10 is not in a(n).
		

Crossrefs

Programs

  • Mathematica
    FromDigits /@ Select[IntegerDigits[Range[2^12], 2], And[PalindromeQ@ Take[#, Floor[Length[#]/2]], PalindromeQ[#]] &] (* Michael De Vlieger, Nov 08 2017 *)

A344550 Nested palindromes.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10101, 11111, 12121, 13131, 14141, 15151, 16161, 17171, 18181, 19191, 20202, 21212, 22222, 23232, 24242
Offset: 1

Views

Author

James S. DeArmon, May 22 2021

Keywords

Comments

Both the right and left halves of each term are themselves palindromes.
Here, "half" means ceiling(m/2) digits for an m-digit term, whereas A240601 uses floor(m/2). - Michael S. Branicky, May 22 2021

Examples

			2222 is a nested palindrome since 22=22, and taking just one side, 2=2. For an example using an odd number of digits, 68686 is a nested palindrome since 686 is a palindrome. Using parentheses to indicate nesting: ( (22) (22) ) and ( (686) (686) ), where, in the second example, the middle-most 6 is repeated for exposition.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[0,10^5],(k=#;f=FromDigits/@(Take[IntegerDigits[k],#]&/@{l=Ceiling[IntegerLength@k/2],-l});
    And@@PalindromeQ/@Join[f,{k}])&] (* Giorgos Kalogeropoulos, Jun 24 2021 *)
    Select[Range[0,25000],AllTrue[{#,FromDigits[Take[IntegerDigits[#],Ceiling[ IntegerLength[ #]/2]]]},PalindromeQ]&] (* Harvey P. Dale, May 15 2022 *)
  • Perl
    foreach $cand (0..200000){
        @a=split("",$cand);
        $b = join("",reverse @a);
        next unless $cand==$b; # palindromes only
        $len = int(@a/2.); $lenA = @a;
        $len++ unless ($lenA/2 == int $lenA/2); # an even half? or include middle digit
        $half = join("",@a[0..($len-1)]);
        $revHalf = join("",reverse @a[0..($len-1)]);
        next unless $half == $revHalf;
        $str .= "$cand, ";
    }
    chop $str;  chop $str;  # remove trailing comma and space
    print "$str\n";  # write to stdout
    
  • Python
    from itertools import 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]:
            if left + mid + right != '0': yield left + mid + right
    def auptod(dd):
      yield 0
      for d in range(1, dd+1):
        yield from (int(p+p[-1-d%2::-1]) for p in pals((d+1)//2))
    print([np for np in auptod(6)]) # Michael S. Branicky, May 22 2021

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.
Showing 1-4 of 4 results.