A345529 Primes that yield a prime when any single digit is replaced by its 10's complement.
3, 5, 7, 17, 47, 71, 107, 223, 401, 823, 827, 857, 883, 2087, 2089, 2539, 3253, 4007, 5051, 5059, 5503, 5507, 7541, 8447, 10247, 12401, 18041, 25303, 33529, 33589, 35533, 40427, 44171, 45557, 53503, 53653, 53899, 54401, 55001, 55009, 55333, 55817, 57077, 71147, 81017, 82003, 93553
Offset: 1
Examples
71147 is a term since 31147, 79147, 71947, 71167 and 71143 are all primes.
Programs
-
Mathematica
q[n_] := PrimeQ[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^5], q] (* Amiram Eldar, Jul 06 2021 *)
-
Python
from sympy import isprime, primerange def comp(d, i): return d[:i] + str((10-int(d[i]))%10) + d[i+1:] def ok(p): d = str(p) return all(isprime(int(comp(d, i))) for i in range(len(d))) print(list(filter(ok, primerange(1, 95000)))) # Michael S. Branicky, Jun 20 2021
Comments