A366310 First of a sequence of exactly n consecutive primes whose squares have the same last digit.
2, 13, 43, 157, 401, 2969, 7237, 30697, 57397, 68239, 576019, 967019, 225769, 6590069, 10942949, 21235127, 57401779, 186564317, 154836067, 117219967, 2598759227, 7470538489, 28594410847, 59107046659, 240456558467, 34511350409, 193861351357, 249423946921, 368059259143
Offset: 1
Examples
a(3) = 43 because the 3 consecutive primes 43, 47, 53 all have squares ending in 9, while the primes 41 and 59 preceding 43 and following 53 have squares ending in 1.
Crossrefs
Cf. A054681.
Programs
-
Maple
N:= 16: # for a(1) .. a(N) V:= Vector(N): p:= 2: q:= 2: count:= 0: d:= 4: i:= 1: while count < N do p:= nextprime(p); if p^2 mod 10 <> d then if i <= N and V[i] = 0 then V[i]:= q; count:= count+1; fi; q:= p; i:= 1; d:= p^2 mod 10; else i:= i+1; fi od: convert(V,list);
-
PARI
upto(n) = { my(res = [], ld = 4, streak = 1); forprime(p = 3, n, nd = p^2 % 10; if(nd == ld, streak++ , if(streak > #res, res = concat(res, vector(streak - #res, i, oo)) ); if(res[streak] == oo, c = p; for(i = 1, streak, c = precprime(c-1); ); res[streak] = c; ); streak = 1; ); ld = nd ); res } \\ David A. Corneth, Oct 07 2023
Extensions
More terms from David A. Corneth, Oct 07 2023
Comments