login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Greater of two consecutive primes, p < q, such that both p*q+p-q and p*q-p+q are prime numbers.
2

%I #15 Nov 24 2019 09:58:47

%S 3,5,29,509,997,1399,1627,3307,4217,5477,5689,6569,6599,7369,7393,

%T 7841,8191,8861,10067,11311,11801,13859,14401,15859,16987,17851,18211,

%U 20593,21101,24169,25013,25339,25621,26209,28019,28409,28439,32009,35677

%N Greater of two consecutive primes, p < q, such that both p*q+p-q and p*q-p+q are prime numbers.

%C 3*5-2=13; 3*5+2=17, 23*29-6=661; 23*29+6=673...

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

%p p:= 1: q:= 2: Res:= NULL:

%p while q < 100000 do

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

%p if isprime(p*q+p-q) and isprime(p*q+q-p) then

%p Res:= Res, q;

%p fi

%p od:

%p Res; # _Robert Israel_, May 10 2017

%t lst={};Do[pp=Prime[n-1];p=Prime[n];d=p-pp;If[PrimeQ[pp*p-d]&&PrimeQ[pp*p+d],AppendTo[lst,p]],{n,2,8!}];lst

%t pqpQ[{p_,q_}]:=Module[{pq=p*q},And@@PrimeQ[{pq+p-q,pq-p+q}]]; Transpose[ Select[Partition[Prime[Range[4000]],2,1],pqpQ]][[2]] (* _Harvey P. Dale_, May 20 2012 *)

%o (PARI) is(n)=my(p); isprime(n) && isprime((p=precprime(n-1))*n+p-n) && isprime(p*n-p+n) \\ _Charles R Greathouse IV_, May 10 2017

%Y Cf. A138111, A138170, A154550, A154551.

%K nonn

%O 1,1

%A _Vladimir Joseph Stephan Orlovsky_, Jan 11 2009

%E Edited by _Omar E. Pol_, Jan 12 2009