login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A345343
Numbers that yield a prime when any single digit is replaced by its digital complement.
1
3, 5, 7, 8, 17, 33, 39, 47, 63, 71, 77, 93, 107, 171, 177, 221, 223, 287, 333, 339, 401, 441, 447, 699, 823, 827, 857, 883, 999, 1421, 1781, 2087, 2089, 2171, 2233, 2539, 3253, 3829, 3963, 4007, 4173, 4977, 5051, 5059, 5503, 5507, 6363, 7217, 7491, 7541, 8447, 10247
OFFSET
1,1
COMMENTS
Digital complement of a digit d is 10-d if d > 0, 0 otherwise.
EXAMPLE
3829 is a term since 7829, 3229, 3889 and 3821 are all primes.
MATHEMATICA
q[n_] := Module[{d = IntegerDigits[n]}, And @@ PrimeQ[Table[FromDigits[ReplacePart [d, i -> If[d[[i]] == 0, d[[i]], 10 - d[[i]]]]], {i, 1, Length[d]}]]]; Select[Range[10^4], q] (* Amiram Eldar, Jun 15 2021 *)
PROG
(Python)
from sympy import isprime
def comp(d, i): return d[:i] + str((10-int(d[i]))%10) + d[i+1:]
def ok(n):
d = str(n)
return all(isprime(int(comp(d, i))) for i in range(len(d)))
print(list(filter(ok, range(1, 11000)))) # Michael S. Branicky, Jun 14 2021
(PARI) f(x) = if (x, 10-x);
isok(m) = {my(d=digits(m)); for (i=1, #d, d[i] = f(d[i]); if (!isprime(fromdigits(d)), return (0)); d[i] = f(d[i]); ); return (1); } \\ Michel Marcus, Jun 15 2021
CROSSREFS
KEYWORD
nonn,base,easy,less
AUTHOR
Lamine Ngom, Jun 14 2021
STATUS
approved