login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A366310 First of a sequence of exactly n consecutive primes whose squares have the same last digit. 0

%I #17 Oct 08 2023 09:05:08

%S 2,13,43,157,401,2969,7237,30697,57397,68239,576019,967019,225769,

%T 6590069,10942949,21235127,57401779,186564317,154836067,117219967,

%U 2598759227,7470538489,28594410847,59107046659,240456558467,34511350409,193861351357,249423946921,368059259143

%N First of a sequence of exactly n consecutive primes whose squares have the same last digit.

%C a(n) > 4.5*10^11 for n >= 30. - _David A. Corneth_, Oct 07 2023

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

%p N:= 16: # for a(1) .. a(N)

%p V:= Vector(N):

%p p:= 2: q:= 2: count:= 0: d:= 4: i:= 1:

%p while count < N do

%p p:= nextprime(p);

%p if p^2 mod 10 <> d then

%p if i <= N and V[i] = 0 then

%p V[i]:= q; count:= count+1;

%p fi;

%p q:= p; i:= 1; d:= p^2 mod 10;

%p else

%p i:= i+1;

%p fi

%p od:

%p convert(V,list);

%o (PARI)

%o upto(n) = {

%o my(res = [], ld = 4, streak = 1);

%o forprime(p = 3, n,

%o nd = p^2 % 10;

%o if(nd == ld,

%o streak++

%o ,

%o if(streak > #res,

%o res = concat(res, vector(streak - #res, i, oo))

%o );

%o if(res[streak] == oo,

%o c = p;

%o for(i = 1, streak,

%o c = precprime(c-1);

%o );

%o res[streak] = c;

%o );

%o streak = 1;

%o

%o );

%o ld = nd

%o ); res

%o } \\ _David A. Corneth_, Oct 07 2023

%Y Cf. A054681.

%K nonn,base

%O 1,1

%A _Robert Israel_ and the late _J. M. Bergot_, Oct 06 2023

%E More terms from _David A. Corneth_, Oct 07 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 24 15:10 EDT 2024. Contains 375417 sequences. (Running on oeis4.)