OFFSET
1,1
COMMENTS
A left- or right-truncatable prime is a prime number from which one digit at a time may be removed from the left or right end until a single-digit prime is reached, with each digit removal resulting in a prime. There exists only one such 60-digit prime: 202075909708030901050930450609080660821035604908735717137397. Since it cannot be extended, there are no such primes with more than 60 digits, so a(60)=1 is the final term of the sequence.
LINKS
Wikipedia, Truncatable prime
EXAMPLE
The 16 two-digit left- or right-truncatable primes with no consecutive zero digits are 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97.
The first 10 three-digit left- or right-truncatable primes with no consecutive zero digits are 103, 107, 113, 131, 137, 139, 167, 173, 179, 197.
The unique 60-digit left- or right-truncatable prime with no consecutive zero digits can be sequentially truncated to a single-digit prime as follows, where each "..." indicates repeated removal of the leftmost digit:
202075909708030901050930450609080660821035604908735717137397
...
2075909708030901050930450609080660821035604908735717137397
207590970803090105093045060908066082103560490873571713739
...
970803090105093045060908066082103560490873571713739
97080309010509304506090806608210356049087357171373
...
6090806608210356049087357171373
609080660821035604908735717137
...
80660821035604908735717137
8066082103560490873571713
806608210356049087357171
...
8210356049087357171
821035604908735717
21035604908735717
2103560490873571
...
71
7
PROG
(Python)
from sympy import isprime
dumps = set({})
route = set({})
nums = [i*(10**j) for i in range(1, 10) for j in range(2)]
def addnum(a):
global route
for j in nums:
b = int("{}{}".format(a, j))
if isprime(b):
if b not in route:
route.add(b)
addnum(b)
for j in nums:
b = int("{}{}".format(j, a))
if isprime(b):
if b not in route:
route.add(b)
addnum(b)
def run():
for i in nums:
if isprime(i):
addnum(i)
run()
CROSSREFS
KEYWORD
nonn,fini,full
AUTHOR
Timothy Smith, Jan 25 2022
STATUS
approved