login
A258337
Smallest prime starting with n that does not appear earlier.
3
11, 2, 3, 41, 5, 61, 7, 83, 97, 101, 113, 127, 13, 149, 151, 163, 17, 181, 19, 2003, 211, 223, 23, 241, 251, 263, 271, 281, 29, 307, 31, 3203, 331, 347, 353, 367, 37, 383, 397, 401, 419, 421, 43, 443, 457, 461, 47, 487, 491, 503, 5101, 521, 53, 541, 557, 563, 571, 587, 59, 601, 613, 6203, 631, 641, 653, 661, 67, 683, 691, 701
OFFSET
1,1
COMMENTS
According to a comment in A018800, every term exists. So the sequence is a permutation of the primes. Indeed, every prime p appears in the sequence either as the p-th term or earlier.
FORMULA
For n>=2, a(n) >= prime(n-1). The equality holds iff prime(n-1) did not already appear as a(k), k<n.
MAPLE
N:= 100: # to get a(1) to a(N)
for n from 1 to N do
p:= n;
if n < 10 then
p1:= 0
else
p1:= A[floor(n/10)];
fi;
if isprime(p) and p > p1 then
A[n]:= p
else
for d from 1 while not assigned(A[n]) do
for i from 1 to 10^d-1 do
p:= 10^d*n+i;
if p > p1 and isprime(p) then
A[n]:= p;
break
fi;
od
od
fi
od:
seq(A[i], i=1..N); # Robert Israel, Jun 29 2015
PROG
(PARI) sw(m, n)=d1=digits(n); d2=digits(m); for(i=1, min(#d1, #d2), if(d1[i]!=d2[i], return(0))); 1
v=[]; n=1; while(n<70, k=1; while(k<10^3, p=prime(k); if(sw(p, n)&&!vecsearch(vecsort(v), p), v=concat(v, p); k=0; n++); k++)); v \\ Derek Orr, Jun 13 2015
(Haskell)
import Data.List (isPrefixOf, delete)
a258337 n = a258337_list !! (n-1)
a258337_list = f 1 $ map show a000040_list where
f x pss = g pss where
g (qs:qss) = if show x `isPrefixOf` qs
then (read qs :: Int) : f (x + 1) (delete qs pss)
else g qss
-- Reinhard Zumkeller, Jul 01 2015
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Vladimir Shevelev, May 27 2015
STATUS
approved