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.

A372142 a(n) is the smallest prime p such that there exist exactly n distinct primes q where q < p and the representation of p in base q is a palindrome.

This page as a plain text file.
%I A372142 #46 May 19 2024 03:19:19
%S A372142 2,3,31,443,23053,86677,11827763,27362989,755827199,1306369439
%N A372142 a(n) is the smallest prime p such that there exist exactly n distinct primes q where q < p and the representation of p in base q is a palindrome.
%C A372142 This is a special case of A372141.
%C A372142 It need not be the case that a(n) is a palindrome in base 2, as 23053 is a counterexample.
%C A372142 For p > 3, one only needs to check q such that q^2 + 1 <= p else p = cc_q = c*(q+1), not prime for c != 1 and q != 2. A similar argument shows that p cannot have an even number of digits in base q, else it would be divisible by (q+1). - _Michael S. Branicky_, Apr 21 2024
%e A372142 a(5) = 86677, as it is palindromic in base 2, 107, 113, 151, and 233, and no smaller number satisfies the property.
%o A372142 (Python)
%o A372142 from math import isqrt
%o A372142 from sympy import sieve
%o A372142 from sympy.ntheory import digits
%o A372142 from itertools import islice
%o A372142 def ispal(v): return v == v[::-1]
%o A372142 def f(p): return sum(1 for q in sieve.primerange(1, isqrt(p-1)+1) if ispal(digits(p, q)[1:]))
%o A372142 def agen():
%o A372142     adict, n = {0:2, 1:3}, 0
%o A372142     for p in sieve:
%o A372142         v = f(p)
%o A372142         if v >= n and v not in adict:
%o A372142             adict[v] = p
%o A372142             while n in adict:
%o A372142                 yield adict[n]; del adict[n]; n += 1
%o A372142 print(list(islice(agen(), 6))) # _Michael S. Branicky_, Apr 21 2024
%Y A372142 Cf. A372141, A002385, A002113.
%Y A372142 Cf. A016041, A007500, A077798.
%K A372142 nonn,base,more
%O A372142 0,1
%A A372142 _Tadayoshi Kamegai_, Apr 21 2024
%E A372142 a(6) from _Jon E. Schoenfield_, Apr 21 2024
%E A372142 a(7) from _Michael S. Branicky_, Apr 21 2024
%E A372142 a(8) from _Michael S. Branicky_, Apr 22 2024
%E A372142 a(9) from _Michael S. Branicky_, Apr 24 2024