login
A397072
a(n) is the first prime p such that the concatenation of the last digits of n consecutive primes starting with p is prime.
2
2, 2, 5, 2, 31, 13, 17, 5, 7, 43, 41, 13, 2, 37, 23, 2, 2, 101, 47, 7, 11, 17, 5, 331, 31, 7, 23, 2, 349, 79, 67, 139, 271, 2, 281, 31, 97, 37, 383, 239, 263, 127, 137, 157, 97, 593, 11, 167, 113, 389, 449, 307, 179, 617, 199, 349, 127, 127, 131, 7, 397, 317, 179, 577, 1487, 659, 307, 31, 379, 37
OFFSET
1,1
LINKS
EXAMPLE
a(5) = 31 because the 5 consecutive primes starting with 31 are 31, 37, 41, 43 and 47, the concatenation of their last digits is 17137, which is prime, and no prime less than 31 works.
MAPLE
P:= select(isprime, [2, seq(i, i=3..10^6, 2)]):
lcat:= proc(L) local i, t;
add((L[i] mod 10)*10^(nops(L)-i), i=1..nops(L))
end proc:
f:= proc(n) local i, j, v;
for i from 1 do
v:= lcat(P[i..i+n-1]);
if isprime(v) then return P[i] fi
od
end proc:
map(f, [$1..100]);
MATHEMATICA
a[n_]:=Module[{p=0}, Until[PrimeQ[FromDigits[Last/@IntegerDigits/@Prime[Range[p, p+n-1]]]], p++]; Prime[p]]; Array[a, 70] (* James C. McMahon, Jul 05 2026 *)
PROG
(Python)
from itertools import islice
from gmpy2 import mpz, is_prime
from sympy import primerange
def agen(LIM=10**6): # generator of terms, capped by LIM
primes = list(primerange(1, LIM+1))
L = [str(p%10) for p in primes] # last digits of primes
n, an = 1, True
while an:
an = next((primes[i] for i in range(len(primes)-n) if is_prime(mpz("".join(L[i:i+n])))), None)
if an: yield an; n += 1
print(list(islice(agen(), 70))) # Michael S. Branicky, Jul 05 2026
CROSSREFS
Sequence in context: A226135 A284464 A038041 * A392900 A392903 A197591
KEYWORD
nonn,base,changed
AUTHOR
Will Gosnell and Robert Israel, Jun 15 2026
STATUS
approved