A258190 Smallest prime not appearing earlier that ends with A045572(n).
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
Links
Programs
-
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
-
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
Formula
A337834 If k is the n-th number ending in 1,3,7, or 9, a(n) is the least prime > k ending in k.
11, 13, 17, 19, 211, 113, 317, 419, 421, 223, 127, 229, 131, 233, 137, 139, 241, 443, 347, 149, 151, 353, 157, 359, 461, 163, 167, 269, 271, 173, 277, 179, 181, 283, 487, 389, 191, 193, 197, 199, 5101, 1103, 5107, 1109, 2111, 2113, 1117, 3119, 3121, 1123, 4127, 1129, 2131, 4133, 2137, 4139, 2141
Offset: 1
Comments
a(n) exists by Dirichlet's theorem on primes in arithmetic progressions.
Examples
For n=3 the third number ending in 1,3,7 or 9 is 7 and the least prime > 7 ending in 7 is a(3)=17. For n=12 the 12th number ending in 1,3,7 or 9 is 29 and the least prime > 29 ending in 29 is a(12)=229.
Links
Programs
-
Maple
f:= proc(n) local d, x; d:= ilog10(n)+1; for x from n + 10^d by 10^d do if isprime(x) then return x fi od end proc: map(f, [seq(seq(10*i+j, j=[1,3,7,9]),i=0..99)];
A338716 Smallest prime ending with decimal expansion of n, for n equal to 5 or relatively prime to 10.
11, 3, 5, 7, 19, 11, 13, 17, 19, 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, 127, 1129, 131, 4133, 137, 139, 2141, 2143, 5147, 149, 151, 1153, 157
Offset: 1
Comments
Included for completeness. This is A338715 with 5 adjoined. See that entry for further information.
a(n) exists by Dirichlet's theorem.
Extensions
More terms from Robert Israel, Nov 11 2020
Comments