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.

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