OFFSET
1,1
LINKS
J.W.L. (Jan) Eerland, Table of n, a(n) for n = 1..100
EXAMPLE
31 is a term because the concatenation of {7,3,3,31} and {13,3,3,7} are respectively 73331 and 13337 which are both prime.
2243 is a term because the concatenation of {7,3,3,31,389,1021,2243} and {3422,1201,983,13,3,3,7} are respectively 7333138910212243 and 3422120198313337 which are both prime.
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)
a*10^(1+ilog10(b))+b
end proc:
A:= 7: x:= 7:
for i from 1 to 50 do
p:= 2:
do
p:= nextprime(p);
y:= tcat(x, p);
if isprime(y) and isprime(rev(y)) then
A:= A, p;
x:= y;
break
fi;
od
od:
A; # after Robert Israel in A113584
MATHEMATICA
w={7}; Do[k=1; q=Monitor[Parallelize[While[True, If[PrimeQ[FromDigits[Join@@IntegerDigits/@Reverse[IntegerDigits[FromDigits[Join@@IntegerDigits/@Append[w, Prime[k]]]]]]]&&PrimeQ[FromDigits[Join@@IntegerDigits/@Append[w, Prime[k]]]], Break[]]; k++]; Prime[k]], {i, k}]; w=Append[w, q], {i, 2, 50}]; w
PROG
(Python)
from itertools import count, islice
from gmpy2 import digits, is_prime, mpz, next_prime
def agen(): # generator of terms
s, r, an = "", "", 7
while True:
yield int(an)
d = digits(an)
s, r, p, sp = s+d, d[::-1]+r, 3, "3"
while not is_prime(mpz(s+sp)) or not is_prime(mpz(sp[::-1]+r)):
p = next_prime(p)
sp = digits(p)
an = p
print(list(islice(agen(), 40))) # Michael S. Branicky, Jan 02 2025
CROSSREFS
KEYWORD
base,nonn,changed
AUTHOR
J.W.L. (Jan) Eerland, Jan 02 2025
STATUS
approved