OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..1000
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
KEYWORD
nonn,base,changed
AUTHOR
Will Gosnell and Robert Israel, Jun 15 2026
STATUS
approved
