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.

A253594 Numbers n that have more than one palindromic representation in bases 2 <= b <= n-2.

Original entry on oeis.org

10, 15, 16, 17, 18, 20, 21, 24, 26, 27, 28, 30, 31, 32, 33, 34, 36, 38, 40, 42, 44, 45, 46, 48, 50, 51, 52, 54, 55, 56, 57, 60, 62, 63, 64, 65, 66, 67, 68, 70, 72, 73, 74, 75, 76, 78, 80, 81, 82, 84, 85, 86, 88, 90, 91, 92, 93, 96, 98, 99, 100, 102, 104, 105, 107, 108, 109, 110, 111, 112, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124
Offset: 1

Views

Author

Christian Perfect, Jan 05 2015

Keywords

Comments

We do not include base n-1, because every n>2 is written '11' in base n-1.

Examples

			10 is written '101' in base 3, and '22' in base 4.
12 is written '22' in base 5, but is not a palindrome in any other base up to 10, so does not belong to this sequence.
		

Programs

  • Mathematica
    palbQ[b_,n_]:=With[{idb=IntegerDigits[n,b]},idb==Reverse[idb]]; Select[Range[150],Total[Boole[Table[palbQ[b,#],{b,2,#-2}]]]>1&] (* Harvey P. Dale, Aug 20 2025 *)
  • Python
    from itertools import count
    def base(n,b):
       while n:
          m = n%b
          yield m
          n = (n-m)//b
    def is_palindrome(seq):
       seq = list(seq)
       l = len(seq)//2
       return seq[:l] == seq[-1:-l-1:-1]
    def a():
       for n in count(2):
          base_representations = [(b,list(base(n,b))) for b in range(2,n-1)]
          pals = [(b,s) for b,s in base_representations if is_palindrome(s)]
          if len(pals)>1:
             yield n
    
  • Python
    from sympy.ntheory import digits
    def ok(n):
        c = 0
        for b in range(2, n-1):
            d = digits(n, b)[1:]
            c += int(d == d[::-1])
            if c == 2: return True
        return c > 1
    print([k for k in range(125) if ok(k)]) # Michael S. Branicky, Feb 05 2024