cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

2, 3, 5, 7, 11, 19, 23, 29, 41, 43, 47, 53, 59, 61, 67, 83, 89, 151, 211, 223, 227, 229, 233, 257, 263, 269, 353, 383, 409, 431, 433, 443, 449, 487, 499, 523, 541, 557, 599, 661, 677, 773, 827, 829, 853, 859, 881, 883, 887, 929, 997, 1447, 1451, 1481, 2111
Offset: 1

Views

Author

Keywords

Comments

At most one permutation of digits of A179239 can occur in this sequence. - David A. Corneth, Jun 28 2018
Is there a term with more than 4 distinct digits? - David A. Corneth, Jun 30 2018
Up through 9999991 (the largest 7-digit prime) there are no terms with more than 4 distinct digits. - Harvey P. Dale, Dec 12 2018
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
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

Crossrefs

Cf. A225421 (only odd digits).
Cf. A244529 for another variant. - M. F. Hasler, Jun 28 2018

Programs

  • Mathematica
    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 *)
    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 *)
  • 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
    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
    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; iM. F. Hasler, Jul 01 2018
    
  • Python
    from itertools import count, islice, combinations_with_replacement
    from sympy.utilities.iterables import multiset_permutations
    from sympy import isprime
    def A039986_gen(): # generator of terms
        for l in count(1):
            xlist = []
            for p in combinations_with_replacement('0123456789',l):
                flag = False
                for q in multiset_permutations(p):
                    if isprime(m:=int(''.join(q))):
                        if flag or q[0]=='0':
                            flag = False
                            break
                        else:
                            flag = True
                            r = m
                if flag:
                    xlist.append(r)
            yield from sorted(xlist)
    A039986_list = list(islice(A039986_gen(),30)) # Chai Wah Wu, Dec 26 2023

Extensions

Name clarified upon the suggestion of Robert Israel, Jun 30 2018