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.

Showing 1-2 of 2 results.

A225035 Primes such that there is a nontrivial rearrangement of the digits which is a prime.

Original entry on oeis.org

13, 17, 31, 37, 71, 73, 79, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 239, 241, 251, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 359, 367, 373, 379, 389, 397, 401, 419, 421
Offset: 1

Views

Author

Jayanta Basu, Apr 24 2013

Keywords

Comments

The new prime is necessarily different from the original prime (so 11, for example) is not a term. - N. J. A. Sloane, Jan 22 2023
Permutations producing leading zeros are allowed: thus 101 is in the sequence because a nontrivial permutation of its digits is 011. - Robert Israel, Aug 13 2019
It seems reasonable to expect that the proportion of n-digit primes that are in this sequence approaches 1 as n increases. - Peter Munn, Sep 13 2022

Examples

			13 is a term since a nontrivial permutation of its digits yields 31, which is also a prime.
		

References

  • H.-E. Richert, On permutation prime numbers, Norsk. Mat. Tidsskr. 33 (1951), p. 50-53.
  • Joe Roberts, Lure of the Integers, Math. Assoc. of Amer., 1992, p. 293.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Second Edition, Cambridge University Press, p. 121.

Crossrefs

See A055387, A359136-A359139 for other versions.

Programs

  • Maple
    dmax:=3: # for all terms of up to dmax digits
    Res:= {}:
    p:= 1:
    do
      p:= nextprime(p);
      if p > 10^dmax then break fi;
      L:= sort(convert(p,base,10),`>`);
      m:= add(L[i]*10^(i-1),i=1..nops(L));
      if assigned(A[m]) then
        if ilog10(A[m])=ilog10(p) then
          Res:= Res union {A[m], p}
        else Res:= Res union {p}
        fi
      else A[m]:= p
      fi
    od:
    sort(convert(Res,list)); # Robert Israel, Aug 13 2019
  • Mathematica
    t={}; Do[p = Prime[n]; list1 = Permutations[IntegerDigits[p]]; If[Length[ Select[Table[FromDigits[n], {n,list1}], PrimeQ]] > 1, AppendTo[t,p]], {n,84}]; t
  • PARI
    is(p) = if(isprime(p), my(d=vecsort(digits(p))); d==vector(#d,x,1)&&return(1); forperm(d, e, my(c = fromdigits(Vec(e))); p!=c && isprime(c) && return(1))); \\ Ruud H.G. van Tol, Jan 22 2023
  • Python
    from sympy import isprime
    from itertools import permutations
    def ok(n):
        if not isprime(n): return False
        perms = (int("".join(p)) for p in permutations(str(n)))
        return any(isprime(t) for t in perms if t != n)
    print([k for k in range(500) if ok(k)]) # Michael S. Branicky, Sep 14 2022
    

Extensions

Edited by N. J. A. Sloane, Jan 22 2023

A358020 Least prime number > prime(n) (n >= 5) whose set of decimal digits coincides with the set of decimal digits of prime(n), or -1 if no such prime exists.

Original entry on oeis.org

1111111111111111111, 31, 71, 191, 223, 229, 113, 73, 4111, 433, 4447, 353, 599, 661, 677, 1117, 337, 97, 383, 8999, 797, 10111, 1013, 701, 1009, 131, 271, 311, 173, 193, 419, 1151, 571, 613, 617, 317, 197, 811, 199, 1193, 719, 911, 2111, 233, 277, 929, 2333, 293, 421, 521, 2557
Offset: 5

Views

Author

Jean-Marc Rebert, Oct 24 2022

Keywords

Examples

			prime(6) = 13 and the prime number 31 have the same set of digits {1,3}, and 31 is the smallest such number, hence a(6) = 31.
prime(13) = 41 and the prime number 4111 have the same set of digits {1,4}, and 4111 is the smallest such number, hence a(13) = 4111.
prime(20) = 71 and the prime number 1117 have the same set of digits {1,7}, and 1117 is the smallest such number, hence a(20) = 1117.
		

Crossrefs

Programs

  • Maple
    N:= 60: # for a(5)..a(N)
    A:= Array(5..N):
    R:= 1111111111111111111:
    A[5]:= R: count:= 1:
    for k from 6 while count < N-4 do
      p:= ithprime(k);
      S:= convert(convert(p,base,10),set);
      if assigned(V[S]) and V[S]<=N then A[V[S]]:= p; count:=count+1;  fi;
      V[S]:= k;
    od:
    convert(A,list); # Robert Israel, Oct 25 2022
  • PARI
    a(n)=my(m=Set(digits(prime(n)))); if(n<5, return()); if(n==5,return(1111111111111111111));forprime(p=prime(n+1), , if(Set(digits(p))==m, return(p)))
    
  • Python
    from sympy import isprime, prime
    from itertools import count, product
    def a(n):
        pn = prime(n)
        s = str(pn)
        for d in count(len(s)):
            for p in product(set(s), repeat=d):
                if p[0] == "0": continue
                t = int("".join(p))
                if t > pn and isprime(t):
                    return t
    print([a(n) for n in range(5, 56)]) # Michael S. Branicky, Oct 25 2022
Showing 1-2 of 2 results.