OFFSET
1,1
COMMENTS
A triple exchange is a permutation of 3 elements in which all 3 three items change position. (For the triple "ABC", that would be "BCA" and "CAB".)
The three prime numbers must be distinct, e.g. we don't allow permuting the three 1's of 1117. - Robert Israel, Sep 15 2025
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
The first term is the prime 113, since 131 and 311 are also prime. Another term is 1013, since 1103 and 1301 are prime.
MAPLE
filter:= proc(n) local L, d, p, n2, n3;
if not isprime(n) then return false fi;
L:= convert(n, base, 10);
d:= nops(L);
for p in combinat:-choose(d, 3) do
n2:= n + 10^(p[1]-1)*(L[p[2]]-L[p[1]]) + 10^(p[2]-1)*(L[p[3]]-L[p[2]]) + 10^(p[3]-1)*(L[p[1]]-L[p[3]]);
n3:= n + 10^(p[1]-1)*(L[p[3]]-L[p[1]]) + 10^(p[2]-1)*(L[p[1]]-L[p[2]]) + 10^(p[3]-1)*(L[p[2]]-L[p[3]]);
if n2 >= 10^(d-1) and n3 >= 10^(d-1) and nops({n, n2, n3})=3 and isprime(n2) and isprime(n3) then return true fi
od;
false
end proc:
select(filter, [seq(i, i=101 .. 2000, 2)]); # Robert Israel, Sep 15 2025
PROG
(Python)
from sympy import isprime
from itertools import combinations, permutations
def ok(n):
if n < 100 or not isprime(n): return False
s = list(str(n))
for i, j, k in combinations(range(len(s)), 3):
pset, w, x = {n}, s[:], s[:]
w[i], w[j], w[k] = w[j], w[k], w[i]
x[i], x[j], x[k] = x[k], x[i], x[j]
if w[0] != "0" and isprime(t:=int("".join(w))): pset.add(t)
if x[0] != "0" and isprime(t:=int("".join(x))): pset.add(t)
if len(pset) == 3: return True
return False
print([k for k in range(1920) if ok(k)]) # Michael S. Branicky, Sep 17 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
James S. DeArmon, Sep 15 2024
EXTENSIONS
Terms corrected by Michael S. Branicky, Sep 17 2024
STATUS
approved
