%I #16 Jul 05 2026 16:34:02
%S 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,
%T 23,2,349,79,67,139,271,2,281,31,97,37,383,239,263,127,137,157,97,593,
%U 11,167,113,389,449,307,179,617,199,349,127,127,131,7,397,317,179,577,1487,659,307,31,379,37
%N a(n) is the first prime p such that the concatenation of the last digits of n consecutive primes starting with p is prime.
%H Robert Israel, <a href="/A397072/b397072.txt">Table of n, a(n) for n = 1..1000</a>
%e 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.
%p P:= select(isprime,[2,seq(i,i=3..10^6,2)]):
%p lcat:= proc(L) local i,t;
%p add((L[i] mod 10)*10^(nops(L)-i),i=1..nops(L))
%p end proc:
%p f:= proc(n) local i,j,v;
%p for i from 1 do
%p v:= lcat(P[i..i+n-1]);
%p if isprime(v) then return P[i] fi
%p od
%p end proc:
%p map(f, [$1..100]);
%t 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 *)
%o (Python)
%o from itertools import islice
%o from gmpy2 import mpz, is_prime
%o from sympy import primerange
%o def agen(LIM=10**6): # generator of terms, capped by LIM
%o primes = list(primerange(1, LIM+1))
%o L = [str(p%10) for p in primes] # last digits of primes
%o n, an = 1, True
%o while an:
%o an = next((primes[i] for i in range(len(primes)-n) if is_prime(mpz("".join(L[i:i+n])))), None)
%o if an: yield an; n += 1
%o print(list(islice(agen(), 70))) # _Michael S. Branicky_, Jul 05 2026
%Y Cf. A007652, A397073.
%K nonn,base,changed
%O 1,1
%A _Will Gosnell_ and _Robert Israel_, Jun 15 2026