login
Primes p that are palindromic in some prime base q, where q < p.
2

%I #30 May 13 2024 15:36:46

%S 3,5,7,13,17,23,31,41,67,71,73,83,107,109,127,151,157,173,199,233,257,

%T 271,277,307,313,353,379,409,419,421,431,443,457,499,521,523,571,587,

%U 599,601,631,643,647,653,691,701,709,719,733,743,757,787,797,809,823,829,857,863,887

%N Primes p that are palindromic in some prime base q, where q < p.

%C If we remove either constraint of q < p or q being prime, then the sequence would be all prime numbers (A000040).

%C By definition it is a superset of A016041, and is a proper superset by construction (e.g., 13 is in the sequence).

%C Some terms have multiple bases that yield palindromic representations, the first being 31 (which is palindromic in both base 2 and base 5). The smallest prime p such that there exist n distinct primes less than p that give palindromic representations of p is A372142(n).

%H Chai Wah Wu, <a href="/A372141/b372141.txt">Table of n, a(n) for n = 1..11371</a> (terms 1..1000 from Tadayoshi Kamegai)

%e 11 is not in this sequence as its representation in base 2 is 1011, in base 3 is 102, in base 5 is 21, in base 7 is 14, none of which are palindromic.

%e 1483 is in this sequence as its representation in base 37 is 131, which is palindromic.

%t a={}; For[i=1, i<=155, i++, flag=0; For[j=1, Prime[j] < Prime[i] && flag==0, j++, If[PalindromeQ[IntegerDigits[Prime[i], Prime[j]]], flag=1; AppendTo[a, Prime[i]]]]]; a (* _Stefano Spezia_, Apr 22 2024 *)

%o (Python)

%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 agen(): yield from (p for p in sieve if any(ispal(digits(p, q)[1:]) for q in sieve.primerange(1, p)))

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

%Y Cf. A372142, A002385, A002113.

%Y Cf. A007500, A016041, A077798.

%K nonn,base

%O 1,1

%A _Tadayoshi Kamegai_, Apr 20 2024