OFFSET
0,1
COMMENTS
Digits can be prepended or appended. We allow prepending by zero and any leading 0 digits upon prepending or removal of the first digit are discarded.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..10000
FORMULA
EXAMPLE
a(8) = 83 since removing any digit or prepending a digit cannot yield a prime; 80, 81 and 82 are not prime; but 83 is prime.
a(84) = 0 is the first 0 term. No removal or addition other than at the end can lead to a prime; and 841, 843, 847 and 849 are not prime.
PROG
(Python)
from gmpy2 import is_prime
def a(n):
s = str(n)
D = set(p for i in range(len(s)) if len(t:=s[:i]+s[i+1:]) and is_prime(p:=int(t)))
if D: return min(D)
A = set(p for i in range(len(s)+1) for d in "0123456789" if is_prime(p:=int(s[:i]+d+s[i:])))
return min(A, default=0)
print([a(n) for n in range(76)])
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Oct 19 2025
STATUS
approved
