login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039986 Primes such that every distinct permutation of digits is composite (including permutations with leading zeros). 7

%I #100 Feb 17 2024 10:31:11

%S 2,3,5,7,11,19,23,29,41,43,47,53,59,61,67,83,89,151,211,223,227,229,

%T 233,257,263,269,353,383,409,431,433,443,449,487,499,523,541,557,599,

%U 661,677,773,827,829,853,859,881,883,887,929,997,1447,1451,1481,2111

%N Primes such that every distinct permutation of digits is composite (including permutations with leading zeros).

%C At most one permutation of digits of A179239 can occur in this sequence. - _David A. Corneth_, Jun 28 2018

%C Is there a term with more than 4 distinct digits? - _David A. Corneth_, Jun 30 2018

%C Up through 9999991 (the largest 7-digit prime) there are no terms with more than 4 distinct digits. - _Harvey P. Dale_, Dec 12 2018

%C The sequence can be seen as a table with the n-digit terms in row n. Row lengths would then be (4, 13, 34, 45, 68, 67, 47, 36, 40, 46, 33, 45, 35, 38, 32, ...). In these rows there are (0, 0, 0, 6, 9, 3, 0, 1, 0, 0, ...) terms with >= 4 distinct digits: this seems to happen only for terms with 4, 5, 6 or 8 digits. I conjecture that there are no more than these 6 + 9 + 3 + 1 = 19 terms (2861, 4027, 4801, 5209, 5623, 5849, 24889, 26561, 40609, 40883, 66541, 66853, 85087, 85843, 86441, 288689, 442469, 558541, 55555429) with 4, and none with 5 or more distinct digits. - _M. F. Hasler_, Jul 01 2018

%C Prime repunits (A004022) are a subset of this sequence. As larger terms are seemingly all near-repdigit primes, it is possible to obtain very large terms. For example: (10^10002 - 1)/9 - 10^2872. - _Hans Havermann_, Jul 08 2018

%H Hans Havermann and M. F. Hasler, <a href="/A039986/b039986.txt">Table of n, a(n) for n = 1..1141</a> (Terms < 10^30; earlier terms from T. D. Noe and David A. Corneth.)

%H Hans Havermann, <a href="http://gladhoboexpress.blogspot.com/2018/08/nlic-primes.html">AEnlic primes</a>.

%t t = {}; Do[p=Prime[n]; If[Length[Select[Table[FromDigits[k], {k,Permutations[IntegerDigits[p]]}], PrimeQ]] == 1, AppendTo[t,p]], {n,330}]; t (* _Jayanta Basu_, May 07 2013 *)

%t Select[Prime[Range[400]],AllTrue[FromDigits/@Rest[ Permutations[ IntegerDigits[#]]], CompositeQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Nov 22 2015 *)

%o (PARI) is(n,d=digits(n))={isprime(n)&&!for(i=1,(#d)!, (n=vecextract(d,numtoperm(#d,i)))!=d&& isprime(fromdigits(n))&& return)} \\ Then: select(is,primes(500)) - _M. F. Hasler_, Jun 28 2018

%o is(n)={isprime(n)||return; my(d=vecsort(digits(n), (a, b)->if(a-b&& t=bittest(650, a)-bittest(650, b),t,a-b)), p=vector(#d,i,i), N(p,i=2)= while((t=p[i]-1)&& while((setsearch(Set(p[i+1..#p]),t)|| d[t]==d[p[i]])&& t--,); !t, i++>#p&& return); i<#p|| bittest(650, d[t])|| return; concat([setminus(Set(p[1..i]),[t]), t, p[i+1..#p]]), t); #d==1|| !until(!p=N(p),(n!=t=fromdigits(vecextract(d,p)))&& isprime(t)&& return)} \\ Produces only inequivalent permutations which can be prime. - _M. F. Hasler_, Jun 28 2018

%o A039986_row(n)={if(n>1, local(D=eval(Vec("0245681379")), u=vectorv(n, i, 10^(n-i)), nextperm()=for(i=2,n,(t=p[i]-1)&& while(setsearch(Set(p[i+1..n]),t)|| d[t]==d[p[i]], t--||break); t|| next; i<n|| bittest(650,d[t])|| return; return(p=concat([setminus(Set(p[1..i]), [t]), t, p[i+1..n]]))), L=List(), f, p, d); forvec(i=vector(n,i,[7^(i==n),10]), vecsum(d=vecextract(D,i))%3|| next; f=0; p=[1..n]; until(!nextperm(), isprime(vecextract(d,p)*u)&& (f&& next(2)|| f=p)); f&& d[f[1]]&& listput(L,vecextract(d,f)*u),1); Set(L), primes(4))} \\ Returns all terms with n digits. - _M. F. Hasler_, Jul 01 2018

%o (Python)

%o from itertools import count, islice, combinations_with_replacement

%o from sympy.utilities.iterables import multiset_permutations

%o from sympy import isprime

%o def A039986_gen(): # generator of terms

%o for l in count(1):

%o xlist = []

%o for p in combinations_with_replacement('0123456789',l):

%o flag = False

%o for q in multiset_permutations(p):

%o if isprime(m:=int(''.join(q))):

%o if flag or q[0]=='0':

%o flag = False

%o break

%o else:

%o flag = True

%o r = m

%o if flag:

%o xlist.append(r)

%o yield from sorted(xlist)

%o A039986_list = list(islice(A039986_gen(),30)) # _Chai Wah Wu_, Dec 26 2023

%Y Cf. A030291, A179239.

%Y Cf. A225421 (only odd digits).

%Y Cf. A244529 for another variant. - _M. F. Hasler_, Jun 28 2018

%K base,nonn

%O 1,1

%A _David W. Wilson_

%E Name clarified upon the suggestion of _Robert Israel_, Jun 30 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 17 23:23 EDT 2024. Contains 371767 sequences. (Running on oeis4.)