A180560 The number of times the n-th prime, p, can become a different prime under any mapping of some single decimal digit <=> with some other single decimal digit.
3, 3, 3, 3, 0, 9, 8, 6, 7, 5, 5, 7, 5, 8, 7, 7, 5, 4, 6, 6, 9, 7, 7, 5, 6, 4, 7, 12, 10, 6, 6, 5, 10, 9, 6, 6, 9, 9, 12, 7, 10, 6, 6, 7, 9, 3, 6, 7, 7, 3, 4, 6, 8, 6, 4, 7, 4, 6, 6, 5, 7, 5, 8, 4, 5, 7, 5, 7, 10, 6, 5, 7, 8, 3, 8, 5, 6, 8, 8, 8, 8, 7, 7, 3, 9, 6, 2, 6, 9, 7, 9, 6, 3, 7, 3, 6, 7, 6, 6, 7, 7, 5, 9, 5
Offset: 1
Examples
2 can become either 3, 5 or 7 under the proper mapping, therefore a(1)=3. 11 cannot become any other prime regardless of the mapping, therefore a(5)=0.
Links
- Robert Price, Table of n, a(n) for n = 1..2000
- Index to Primes, Primes that become a different prime under some mapping.
Programs
-
Mathematica
fQ[n_] := Block[{id = IntegerDigits@n}, (MemberQ[id, s[[1]]] || MemberQ[id, s[[2]]]) && PrimeQ[ FromDigits[id /. {s[[1]] -> s[[2]], s[[2]] -> s[[1]] }] ]]; t = Sort@ Flatten@ Table[s = {j, k}; Select[ Prime@ Range@ 100, fQ], {j, 0, 8}, {k, j + 1, 9}]; Table[ Length@ Position[t, Prime@ n], {n, 100}]
-
Python
from sympy import isprime, prime def a(n): s = str(prime(n)) return len(set(t for t in (s.translate({ord(c):ord(d), ord(d):ord(c)}) for c in set(s) for d in "0123456789" if d!=c) if isprime(int(t)))) print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Oct 31 2023
Extensions
a(101)-a(104) corrected by Robert Price, Oct 31 2023
Comments