login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

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

%I #46 May 19 2024 03:19:19

%S 2,3,31,443,23053,86677,11827763,27362989,755827199,1306369439

%N 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 This is a special case of A372141.

%C It need not be the case that a(n) is a palindrome in base 2, as 23053 is a counterexample.

%C 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 a(5) = 86677, as it is palindromic in base 2, 107, 113, 151, and 233, and no smaller number satisfies the property.

%o (Python)

%o from math import isqrt

%o from sympy import sieve

%o from sympy.ntheory import digits

%o from itertools import islice

%o def ispal(v): return v == v[::-1]

%o def f(p): return sum(1 for q in sieve.primerange(1, isqrt(p-1)+1) if ispal(digits(p, q)[1:]))

%o def agen():

%o adict, n = {0:2, 1:3}, 0

%o for p in sieve:

%o v = f(p)

%o if v >= n and v not in adict:

%o adict[v] = p

%o while n in adict:

%o yield adict[n]; del adict[n]; n += 1

%o print(list(islice(agen(), 6))) # _Michael S. Branicky_, Apr 21 2024

%Y Cf. A372141, A002385, A002113.

%Y Cf. A016041, A007500, A077798.

%K nonn,base,more

%O 0,1

%A _Tadayoshi Kamegai_, Apr 21 2024

%E a(6) from _Jon E. Schoenfield_, Apr 21 2024

%E a(7) from _Michael S. Branicky_, Apr 21 2024

%E a(8) from _Michael S. Branicky_, Apr 22 2024

%E a(9) from _Michael S. Branicky_, Apr 24 2024