login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Smallest prime not appearing earlier that ends with A045572(n).
3

%I #37 Nov 03 2021 06:15:08

%S 11,3,7,19,211,13,17,419,421,23,127,29,31,233,37,139,41,43,47,149,151,

%T 53,157,59,61,163,67,269,71,73,277,79,181,83,487,89,191,193,97,199,

%U 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

%N Smallest prime not appearing earlier that ends with A045572(n).

%C 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.

%H Peter J. C. Moses, <a href="/A258190/b258190.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Pri#piden">Index entries for primes involving decimal expansion of n</a>

%F a(n) >= A045572(n). The equality holds iff A045572(n) is a prime that did not already appear as a(k), k<n.

%p r:= -1: Used:= 'Used':

%p for n from 1 to 1000 do

%p r:= r+2;

%p if r mod 5 = 0 then r:= r+2 fi;

%p d:= 10^(1+ilog10(r));

%p for x from r by d do

%p if isprime(x) and not assigned(Used[x]) then

%p a[n]:= x;

%p Used[x]:= true;

%p break

%p fi

%p od

%p od:

%p seq(a[n],n=1..1000); # _Robert Israel_, May 27 2015

%o (PARI) \\with first line from A045572 by Charles R Greathouse IV

%o 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

%o (Python)

%o from sympy import isprime

%o def aupton(terms):

%o alst, aset = [], set()

%o for n in range(1, terms+1):

%o ending = 2*n - 1 + (n+1)//4 * 2 # A045572

%o i, pow10 = ending, 10**len(str(ending))

%o while i in aset or not isprime(i): i += pow10

%o alst.append(i); aset.add(i)

%o return alst

%o print(aupton(68)) # _Michael S. Branicky_, Nov 03 2021

%Y Cf. A000040, A045572, A258083, A338715.

%K nonn,base

%O 1,1

%A _Vladimir Shevelev_, May 23 2015