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.
LINKS
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