A371403 Least k such that prime(k), prime(k+1), prime(k+2), ..., prime(k+n) all have the same last digit.
34, 258, 2147, 11582, 62192, 274810, 1500309, 2235294, 10919138, 24000612, 3074210315, 6244442805, 6244442805, 143338476264, 244844614858
Offset: 1
Examples
a(1) = A107730(1) = 34 because prime(34) = 139, prime(35) = 149, both end with the digit 9, and no two consecutive smaller primes end with the same digit. a(2) = 258 because prime(258) = 1627, prime(259) = 1637, prime(260) = 1657 with the same last digit 7, and no three consecutive smaller primes have the same last digit. a(4) = A371390(1).
Programs
-
Maple
nn:=15*10^6: for n from 2 to 7 do : ii:=0:d:=array(1..n): for m from 1 to nn while(ii=0) do: lst:={}: for k from 1 to n do: d[k]:=irem(ithprime(m+k-1),10): lst:=lst union {d[k]}: od: if lst={d[1]} then printf(`%d %d \n`,n-1,m):ii:=1: else fi: od: od:
-
Mathematica
a[n_] := Module[{v = Mod[Prime[Range[n + 1]], 10], k = 1, p}, p = Prime[n + 1]; While[! SameQ @@ v, p = NextPrime[p]; v = Join[Rest[v], {Mod[p, 10]}]; k++]; k]; Array[a, 6] (* Amiram Eldar, Mar 21 2024 *)
-
PARI
upto(n) = { n += 30; my(res = List(), q = 2, t = 1, ld = 2, nld, streak = 0); forprime(p = 3, oo, nld = p%10; if(nld == ld, streak++; if(streak > #res, listput(res, t-streak+1); print1(t-streak+1", "); ) , streak = 0 ); q = p; ld = nld; t++; if(t > n, return(res); ) ); res } \\ David A. Corneth, Mar 23 2024
Extensions
a(7)-a(10) from Amiram Eldar, Mar 21 2024
a(11)-a(13) from David A. Corneth, Mar 22 2024
a(14) from Michael S. Branicky, May 15 2025
a(15) from Michael S. Branicky, May 21 2025
Comments