OFFSET
1,1
COMMENTS
From any term back to and including the first, digit by digit, right to left, we can read the resulting primes backwards.
EXAMPLE
a(3) = 11 because 11 is the smallest unused odd prime such that the concatenated reverse terms R(a(3))||R(a(2))||R(a(1)) = 1153 is prime. Trying the smallest unused odd prime 7 fails because 753 = 3*251, a composite number.
a(5) = 29 as its reverse 92 concatenated with the reversed chain of the previous reversed terms 7, 11, 5, 3, gives 9271153, a prime, and no smaller unused odd prime satisfies that condition.
MAPLE
rev:= proc(n) local L, i; L:= convert(n, base, 10); add(L[-i]*10^(i-1), i=1..nops(L)) end proc:
tcat:= proc(a, b) 10^(1+ilog10(b))*a+b end proc:
Q:= 3: S:= {3}: p:= 3: count:= 1: R:= 3:
while count < 100 do
q:= p;
do
if not member(q, S) then
rq:= rev(q);
if isprime(tcat(rq, Q)) then
count:= count+1;
R:= R, q;
Q:= tcat(rq, Q);
S:= S union {q};
if q = p then p:= nextprime(p) fi;
break
fi;
fi;
q:= nextprime(q);
od;
od:
R; # Robert Israel, Dec 21 2022
MATHEMATICA
a[1] = 3; a[n_] := a[n] = Module[{s = Array[a, n - 1], p = 5}, While[MemberQ[s, p] || ! PrimeQ[FromDigits @ Reverse @ Flatten @ IntegerDigits[Join[s, {p}]]], p = NextPrime[p]]; p]; Array[a, 50] (* Amiram Eldar, Dec 17 2022 *)
PROG
(Python)
from itertools import islice
from sympy import isprime, nextprime
def agen(): # generator of terms
alst, aset, arev, minp = [], set(), "", 3
while True:
p = minp
while p in aset or not isprime(int(str(p)[::-1] + arev)):
p = nextprime(p)
yield p; alst.append(p); aset.add(p); arev = str(p)[::-1] + arev
while minp in aset: minp = nextprime(minp)
print(list(islice(agen(), 53))) # Michael S. Branicky, Dec 16 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Tamas Sandor Nagy, Dec 16 2022
STATUS
approved