login
Least k such that prime(k), prime(k+1), prime(k+2), ..., prime(k+n) all have the same last digit.
0

%I #25 Mar 23 2024 20:35:31

%S 34,258,2147,11582,62192,274810,1500309,2235294,10919138,24000612,

%T 3074210315,6244442805,6244442805

%N Least k such that prime(k), prime(k+1), prime(k+2), ..., prime(k+n) all have the same last digit.

%C The interest in studying a sequence of n consecutive prime numbers having the same last digit is to look at the behavior of the rarefaction of these numbers when n becomes large.

%C a(k) > 10^10 for k >= 14. - _David A. Corneth_, Mar 22 2024

%e 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.

%e 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.

%e a(4) = A371390(1).

%p nn:=15*10^6:

%p for n from 2 to 7 do :

%p ii:=0:d:=array(1..n):

%p for m from 1 to nn while(ii=0)

%p do:

%p lst:={}:

%p for k from 1 to n do:

%p d[k]:=irem(ithprime(m+k-1),10):

%p lst:=lst union {d[k]}:

%p od:

%p if lst={d[1]}

%p then

%p printf(`%d %d \n`,n-1,m):ii:=1:

%p else

%p fi:

%p od:

%p od:

%t 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 *)

%o (PARI)

%o upto(n) = {

%o n += 30;

%o my(res = List(), q = 2, t = 1, ld = 2, nld, streak = 0);

%o forprime(p = 3, oo,

%o nld = p%10;

%o if(nld == ld,

%o streak++;

%o if(streak > #res,

%o listput(res, t-streak+1);

%o print1(t-streak+1", ");

%o )

%o ,

%o streak = 0

%o );

%o q = p;

%o ld = nld;

%o t++;

%o if(t > n,

%o return(res);

%o )

%o );

%o res

%o } \\ _David A. Corneth_, Mar 23 2024

%Y Cf. A000040, A107730, A129750, A371390.

%K nonn,base,hard,more

%O 1,1

%A _Michel Lagneau_, Mar 21 2024

%E a(7)-a(10) from _Amiram Eldar_, Mar 21 2024

%E a(11)-a(13) from _David A. Corneth_, Mar 22 2024