OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..635
EXAMPLE
2, 23, 239, 23911, etc. are primes.
MAPLE
A:= [1, 3, 7, 9]: B:= [1, 3, 7, 9]:
P:= 3, 7, 9, op(zip((s, t) -> s*10+t, A, B)):
for d from 1 to 6 do
P:= P, op(zip(proc(s, t) local i; seq(10^(d+1)*s + 10^d*i + t, i=0..9) end proc, A, B)):
A:= map(proc(t) local i; seq(10*t+i, i=0..9) end proc, A);
B:= map(proc(t) local i; seq(10^d*i+t, i=0..9) end proc, B);
P:= P, op(zip((s, t) -> 10^(d+1)*s+t, A, B));
od:
P:= [P]:
R:= 2: p:= 2:
for i from 2 to 50 do
for j from 1 do
v:= p*10^(1+ilog10(P[j]))+P[j];
if isprime(v) then
p:= v;
R:= R, P[j];
P:= subsop(j=NULL, P);
break
fi
od od:
R; # Robert Israel, Nov 15 2023
PROG
(Python)
from gmpy2 import is_prime
from itertools import count, islice, product
def bgen(): # generator of palindromic decimal strings ending in 1, 3, 7, 9
yield from "379"
for digits in count(2):
for first in "1379":
for left in product("0123456789", repeat=(digits-2)//2):
left = "".join(left)
right = left[::-1]
for mid in [[""], "0123456789"][digits%2]:
yield first + left + mid + right + first
def agen():
alst, aset, concat = [2], {"2"}, "2"
while True:
yield alst[-1]
g = bgen()
s = next(g)
while "start" in s or s in aset or not is_prime(int(concat + s)):
s = next(g)
concat += s
aset.add(s)
alst.append(int(s))
print(list(islice(agen(), 45))) # Michael S. Branicky, Nov 18 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Sep 22 2003
EXTENSIONS
More terms from Sam Alexander, Nov 17 2003
More terms from David Wasserman, Jul 13 2005
STATUS
approved