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!)
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. 1
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
5,1
LINKS
EXAMPLE
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.
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
PROG
(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
CROSSREFS
Sequence in context: A281301 A286481 A168334 * A095434 A276377 A183085
KEYWORD
nonn,base
AUTHOR
Jean-Marc Rebert, Oct 24 2022
STATUS
approved

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 May 8 10:51 EDT 2024. Contains 372332 sequences. (Running on oeis4.)