login
Primes p such that p=prime(k), prime(k+1), and prime(k+2) end in the same digit.
1

%I #25 Sep 08 2022 08:46:24

%S 1627,3089,4297,4831,6481,6793,8543,11027,11867,13421,13649,14177,

%T 17509,17807,18839,18859,20359,20411,22501,22511,22963,22973,24923,

%U 25189,26449,26459,27367,27541,28309,29443,29453,31081,32203,32381,34919,35171,35281,36343,36353,37087,37223,37243,38923

%N Primes p such that p=prime(k), prime(k+1), and prime(k+2) end in the same digit.

%H Robert Israel, <a href="/A328452/b328452.txt">Table of n, a(n) for n = 1..10000</a>

%e (p,q,r) = (1627,1637,1657), are three primes which are consecutive and end in the same digit. Hence, p=1627 is a member of this sequence.

%p q:= 3: r:= 5: count:= 0: R:= NULL:

%p while count < 100 do

%p p:= q; q:= r; r:= nextprime(r);

%p if p-q mod 10 = 0 and q-r mod 10 = 0 then count:= count+1; R:= R, p; fi

%p od:

%p R; # _Robert Israel_, May 08 2020

%t First /@ Select[Partition[Prime@ Range@ 4105, 3, 1], Length@ Union@ Mod[#, 10] == 1 &] (* _Giovanni Resta_, Oct 16 2019 *)

%o (Magma) f:=func<p,m|p mod 10 eq m and NextPrime(p) mod 10 eq m and NextPrime(NextPrime(p)) mod 10 eq m>; a:=[]; for p in PrimesUpTo(40000) do if f(p,1) or f(p,3) or f(p,7) or f(p,9) then Append(~a,p); end if; end for; a; // _Marius A. Burtea_, Oct 16 2019

%o (PARI) isok(p) = {if (isprime(p), my(d = p % 10); my(q = nextprime(p+1), r = nextprime(q+1)); (d == (q % 10)) && (d == (r % 10)););} \\ _Michel Marcus_, Oct 17 2019

%Y Cf. A000040, A290450, A054681.

%K nonn,base

%O 1,1

%A _Philip Mizzi_, Oct 15 2019