login
A389929
Smallest prime number obtained by removing or adding a single digit anywhere in n, or 0 if no such prime exists.
3
2, 11, 2, 3, 41, 5, 61, 7, 83, 19, 101, 11, 2, 3, 149, 5, 163, 7, 181, 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 401, 41, 2, 3, 443, 5, 461, 7, 487, 149, 5, 5, 2, 3, 5, 5, 5, 5, 5, 5, 601, 61, 2, 3, 641, 5, 661, 7, 683, 269, 7, 7, 2, 3, 7, 5
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
FORMULA
0 < a(p) <= p for p prime.
A211396(n) <= a(n) <= A062584(n).
a(n) = 0 if n in A014263 intersection A032352.
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)])
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Oct 19 2025
STATUS
approved