login
Smallest prime number Q such that the sum prime(n)+prime(n+1)+Q is a prime number.
1

%I #19 Mar 14 2022 17:44:58

%S 2,3,5,5,5,7,5,5,7,7,3,5,5,7,3,19,7,3,11,5,5,5,7,5,13,7,13,7,5,11,5,3,

%T 5,5,7,3,11,7,7,7,7,7,5,7,5,11,5,7,5,5,7,7,7,13,3,31,7,23,5,5,11,7,13,

%U 7,11,5,5,7,5,7,7,7,3,5,7,37,11,11,11,11,13

%N Smallest prime number Q such that the sum prime(n)+prime(n+1)+Q is a prime number.

%H Pierre CAMI, <a href="/A246401/b246401.txt">Table of n, a(n) for n = 1..10000</a>

%e 2+3+2=7 is prime so a(1)=2.

%e 3+5+3=11 is prime so a(2)=3.

%e 5+7+3=15 is composite, and 5+7+5=17 is prime so a(3)=5.

%t spn[n_]:=Module[{p=2},While[!PrimeQ[n+p],p=NextPrime[p]];p]; spn/@ (Total/@ Partition[Prime[Range[100]],2,1]) (* _Harvey P. Dale_, Mar 14 2022 *)

%o (PFGW & SCRIPT)

%o SCRIPT

%o DIM k

%o DIM n,0

%o OPENFILEOUT myf,a(n).txt

%o LABEL loop1

%o SET n,n+1

%o IF n>10000 THEN END

%o SET k,0

%o LABEL loop2

%o SET k,k+1

%o PRP p(n)+p(n+1)+p(k)

%o IF ISPRP then GOTO a

%o GOTO loop2

%o LABEL a

%o WRITE myf,t

%o GOTO loop1

%o (PARI) a(n) = t=prime(n)+prime(n+1); k=1; while(!isprime(t+q=prime(k)), k++); q \\ _Colin Barker_, Aug 25 2014

%Y Cf. A246400.

%K nonn

%O 1,1

%A _Pierre CAMI_, Aug 25 2014