A359136 Primes such that there is a nontrivial permutation which when applied to the digits produces a prime (Version 1).
11, 13, 17, 31, 37, 71, 73, 79, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 419, 421
Offset: 1
Links
- Andrew Howroyd, Table of n, a(n) for n = 1..1000
Crossrefs
Programs
-
PARI
isok(n)={my(v=vecsort(digits(n))); if(#Set(v)<#v, 1, forperm(v, u, my(t=fromdigits(Vec(u))); if(isprime(t) && t<>n, return(1))); 0)} \\ Andrew Howroyd, Jan 22 2023
-
Python
from sympy import isprime from itertools import permutations as P def ok(n): if not isprime(n): return False if len(s:=str(n)) > len(set(s)): return True return any(isprime(t) for t in (int("".join(p)) for p in P(s)) if t!=n) print([k for k in range(422) if ok(k)]) # Michael S. Branicky, Jan 23 2023
Extensions
More than the usual number of terms are shown in order to distinguish this from neighboring sequences.
Incorrect terms removed by Andrew Howroyd, Jan 22 2023
Comments