OFFSET
1,1
COMMENTS
Repeatedly removing a digit from either the left or right produces only primes. There are 149677 terms in this sequence, ending with 8939662423123592347173339993799.
The number of n-digit terms is A298048(n). - Jon E. Schoenfield, Jan 28 2022
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
I. O. Angell and H. J. Godwin, On Truncatable Primes, Math. Comput. 31, 265-267, 1977.
T. D. Noe, Plot of all terms
Carlos Rivera, Puzzle 2: Prime Strings, The Prime Puzzles and Problems Connection.
Daniel Starodubtsev, Full sequence
Eric Weisstein, MathWorld: Truncatable Prime
EXAMPLE
139 is here because (removing 9 from the right) 13 is prime and (removing 1 from the left) 3 is prime.
MATHEMATICA
Clear[s]; s[0]={2, 3, 5, 7}; n=1; While[s[n]={}; Do[k=s[n-1][[i]]; Do[p=j*10^n+k; If[PrimeQ[p], AppendTo[s[n], p]], {j, 9}]; Do[p=10*k+j; If[PrimeQ[p], AppendTo[s[n], p]], {j, 9}], {i, Length[s[n-1]]}]; s[n]=Union[s[n]]; Length[s[n]]>0, n++ ]; t=s[0]; Do[t=Join[t, s[i]], {i, n}]; t
PROG
(Python)
from sympy import isprime
def agen():
primes = [2, 3, 5, 7]
while len(primes) > 0:
yield from primes
cands = set(int(d+str(p)) for p in primes for d in "123456789")
cands |= set(int(str(p)+d) for p in primes for d in "1379")
primes = sorted(c for c in cands if isprime(c))
afull = [an for an in agen()]
print(afull[:60]) # Michael S. Branicky, Aug 04 2022
CROSSREFS
KEYWORD
base,fini,nonn
AUTHOR
T. D. Noe, Feb 11 2008
STATUS
approved