login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Numbers n such that the sum of n and the largest prime<n is prime, and the sum of n and the least prime>n is also prime.
4

%I #25 Mar 09 2016 16:37:57

%S 6,24,30,36,50,54,78,84,114,132,144,156,174,210,220,252,294,300,306,

%T 330,360,378,474,492,510,512,528,546,560,594,610,650,660,690,714,720,

%U 762,780,800,804,810,816,870,912,996,1002,1068,1074,1104,1120,1170,1176,1190,1210,1236,1262

%N Numbers n such that the sum of n and the largest prime<n is prime, and the sum of n and the least prime>n is also prime.

%C This sequence is the intersection of A249624 and A249666.

%H Chai Wah Wu, <a href="/A249667/b249667.txt">Table of n, a(n) for n = 1..3410</a>

%e 114 is in the sequence because the least prime>114 is 127 and 114+127=241 is prime; the largest prime<114 is 113 and 114+113=227 is prime. Also, 114 is in A249624 and A249666.

%t Select[Range[1500],AllTrue[#+{NextPrime[#],NextPrime[#,-1]},PrimeQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Mar 09 2016 *)

%o (PARI) {for(i=3,2*10^3,k=i+nextprime(i+1);q=i+precprime(i-1);if(isprime(k)&&isprime(q),print1(i,", ")))}

%o (Python)

%o from gmpy2 import is_prime, next_prime

%o A249667_list, p = [], 2

%o for _ in range(10**4):

%o ....q = next_prime(p)

%o ....n1 = 2*p+1

%o ....n2 = p+q+1

%o ....while n1 < p+q:

%o ........if is_prime(n1) and is_prime(n2):

%o ............A249667_list.append(n1-p)

%o ........n1 += 2

%o ........n2 += 2

%o ....p = q # _Chai Wah Wu_, Dec 06 2014

%Y Cf. A249624, A249666, A249676.

%K nonn

%O 1,1

%A _Antonio Roldán_, Dec 03 2014