login
a(n) is the least prime p such that n - p is the reverse of a prime, where leading 0's are not allowed, or -1 if there is no such p.
2

%I #21 Feb 21 2026 09:11:42

%S 2,2,3,2,3,2,3,-1,5,2,3,2,2,3,2,2,3,5,5,7,7,11,13,11,11,13,13,17,19,2,

%T 2,3,2,2,3,2,2,3,5,5,7,7,11,13,11,11,13,13,17,19,17,17,19,19,23,43,23,

%U 23,31,29,29,31,29,29,31,31,53,37,37,2,3,2,2,3,2,3,7,2,3,7,5,11,7,11,17,13

%N a(n) is the least prime p such that n - p is the reverse of a prime, where leading 0's are not allowed, or -1 if there is no such p.

%C Conjecture: a(n) = -1 only for n = 11.

%H Robert Israel, <a href="/A393460/b393460.txt">Table of n, a(n) for n = 4..10000</a>

%e a(15) = 2 because 2 is prime and 15 - 2 = 13 is the reverse of the prime 31.

%p rev:= proc(n) local L,i;

%p L:= convert(n,base,10);

%p add(L[-i]*10^(i-1),i=1..nops(L))

%p end proc:

%p P:= select(isprime,[2,seq(i,i=3..1000,2)]):

%p revP:= sort(map(rev,P)):

%p nP:= nops(P):

%p V:= Vector(1000,-1):

%p for i from 1 to nP do

%p for j from 1 to nP while P[i]+revP[j] <= 1000 do

%p v:= P[i]+revP[j]; if V[v]=-1 then V[v]:= P[i] fi

%p od od:

%p convert(V[4..1000],list);

%o (Python)

%o from sympy import isprime

%o def a393460(n):

%o for p in range(2, n):

%o if isprime(p):

%o diff = n - p

%o if diff % 10 == 0:

%o continue

%o if isprime(int(str(diff)[::-1])):

%o return p

%o return -1

%o seq = [a393460(n) for n in range(4, 91)]

%o print(seq) # _Aitzaz Imtiaz_, Feb 20 2026

%o (PARI) a(n) = forprime(p=2, n, my(x=Vecrev(digits(n-p))); if (#x && x[1] && isprime(fromdigits(x)), return(p))); -1; \\ _Michel Marcus_, Feb 21 2026

%Y Cf. A391563, A392264.

%K sign,base,look

%O 4,1

%A _Robert Israel_, Feb 15 2026

%E Name edited by _Michel Marcus_, Feb 21 2026