login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A258190
Smallest prime not appearing earlier that ends with A045572(n).
3
11, 3, 7, 19, 211, 13, 17, 419, 421, 23, 127, 29, 31, 233, 37, 139, 41, 43, 47, 149, 151, 53, 157, 59, 61, 163, 67, 269, 71, 73, 277, 79, 181, 83, 487, 89, 191, 193, 97, 199, 101, 103, 107, 109, 2111, 113, 1117, 3119, 3121, 1123, 4127, 1129, 131, 4133, 137, 4139, 2141, 2143, 5147, 11149, 1151, 1153, 4157, 4159, 2161, 1163, 167, 3169
OFFSET
1,1
COMMENTS
Using Dirichlet's theorem, we conclude that every term exists. So the sequence is a permutation of the odd primes other than 5. Indeed, an odd prime p other than 5 is either in its natural place in A045572 or appears earlier than that.
FORMULA
a(n) >= A045572(n). The equality holds iff A045572(n) is a prime that did not already appear as a(k), k<n.
MAPLE
r:= -1: Used:= 'Used':
for n from 1 to 1000 do
r:= r+2;
if r mod 5 = 0 then r:= r+2 fi;
d:= 10^(1+ilog10(r));
for x from r by d do
if isprime(x) and not assigned(Used[x]) then
a[n]:= x;
Used[x]:= true;
break
fi
od
od:
seq(a[n], n=1..1000); # Robert Israel, May 27 2015
PROG
(PARI) \\with first line from A045572 by Charles R Greathouse IV
a(n) = {n = 10*(n>>2)+[-1, 1, 3, 7][n%4+1]; my(d = digits(n), m = matrix(#d + 1, 2), w=0); m[1, 2] = d[#d] - 10; for(i = 2, matsize(m)[1], m[i, 1]=10^(i-2)*d[#d-i+2] + m[i-1, 1]; if(m[i-1, 1] == m[i, 1], m[i, 2]=m[i-1, 2], j=m[i, 1]==m[i-1, 2]; while(!isprime(10^(i-1)*j+m[i, 1]), j++); m[i, 2]=10^(i-1)*j+m[i, 1])); m[matsize(m)[1], 2]} \\ David A. Corneth, May 25 2015
(Python)
from sympy import isprime
def aupton(terms):
alst, aset = [], set()
for n in range(1, terms+1):
ending = 2*n - 1 + (n+1)//4 * 2 # A045572
i, pow10 = ending, 10**len(str(ending))
while i in aset or not isprime(i): i += pow10
alst.append(i); aset.add(i)
return alst
print(aupton(68)) # Michael S. Branicky, Nov 03 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Vladimir Shevelev, May 23 2015
STATUS
approved