A225193
Composite numbers such that every non-identity permutation gives a prime.
Original entry on oeis.org
14, 16, 20, 30, 32, 34, 35, 38, 50, 70, 74, 76, 91, 92, 95, 98, 110, 118, 119, 133, 772, 775, 778, 779, 1118, 3337, 7771, 77779
Offset: 1
772 is a member since both 727 and 277 are primes.
-
t={}; Do[p=Permutations[IntegerDigits[n]]; c=Length[p]; cn=Length[Select[Table[FromDigits[k],{k,p}], PrimeQ]]; If[!PrimeQ[n] && c>1 && cn==c-1, AppendTo[t,n]], {n,10,100000}]; t
-
from sympy import isprime
from itertools import count, islice, permutations
def agen(): yield from (k for k in count(1) if len(set(s:=str(k)))!=1 and not isprime(k) and all((t:=int("".join(m)))==k or isprime(t) for m in permutations(s)))
print(list(islice(agen(), 28))) # Michael S. Branicky, Dec 29 2023
A327822
Numbers k such that when cyclically permuting the digits of k any number of times, any prime obtained is followed by a composite number and vice-versa.
Original entry on oeis.org
14, 16, 19, 20, 23, 29, 30, 32, 34, 35, 38, 41, 43, 47, 50, 53, 59, 61, 67, 70, 74, 76, 83, 89, 91, 92, 95, 98, 1015, 1018, 1070, 1075, 1099, 1132, 1136, 1163, 1216, 1238, 1274, 1303, 1321, 1339, 1361, 1475, 1510, 1517, 1535, 1570, 1574, 1612, 1630, 1631, 1636
Offset: 1
When cyclically permuting the digits of 961990 one gets the numbers 961990, 619909, 199096, 990961, 909619, 96199 and these numbers are composite, prime, composite, prime, composite, prime, respectively, so 961990 (and each of these cyclic permutations except 96199) is a term of the sequence.
A more graphical representation:
961990 C
/ \ / \
096199 619909 P P
| | | |
909619 199096 C C
\ / \ /
990961 P
-
eva(n) = subst(Pol(n), x, 10)
rot(n) = if(#Str(n)==1, v=vector(1), v=vector(#n-1)); for(i=2, #n, v[i-1]=n[i]); u=vector(#n); for(i=1, #n, u[i]=n[i]); v=concat(v, u[1]); v
is(n) = my(nn=#Str(n), u=[], v=vector(nn, x, x%2==0), w=vector(nn, x, x%2==1), d=digits(n), r=rot(d)); if(nn%2==1, return(0)); u=concat(u, [ispseudoprime(eva(d))]); u=concat(u, ispseudoprime(eva(r))); while(1, r=rot(r); if(r==d, if(u==v || u==w, return(1)); return(0)); u=concat(u, ispseudoprime(eva(r))))