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”).

Least number k such that average of {prime(i) | k - n <= i <= k + n} is prime(k), or -1 if no such number exists.
1

%I #24 Sep 07 2024 08:54:33

%S 1,3,22,7,94,16,20,10,12,166,727,40,37,71,702,56,41,76,33,424,314,133,

%T 71,726,241,35,618,205,78,138,1096,1096,111,49,512,2006,5790,504,2634,

%U 1497,199,1344,181,2404,2237,162,241,470,667,81,106,2940,209,209,5549

%N Least number k such that average of {prime(i) | k - n <= i <= k + n} is prime(k), or -1 if no such number exists.

%H Amiram Eldar, <a href="/A364163/b364163.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = A000720(A082080(n)). - _Michel Marcus_, Jul 12 2023

%e a(0) = 1, because 2/1 = 2 = prime(1), and no lesser number satisfies this.

%e a(1) = 3, because (3+5+7)/3 = 5 = prime(3), and no lesser number satisfies this.

%t a[n_] := Module[{ps = Prime[Range[2*n+1]], k = n+1}, While[Total[ps] != (2*n+1)* ps[[n+1]], ps = Join[Rest[ps], {NextPrime[ps[[-1]]]}]; k++]; k]; Array[a, 55, 0] (* _Amiram Eldar_, Sep 07 2024 *)

%o (PARI) a(n) = my(k=n+1); while(sum(i=k-n, k+n, prime(i)) != (2*n+1)*prime(k), k++); k; \\ _Michel Marcus_, Jul 12 2023

%Y Cf. A000720, A082080, A363168.

%K sign

%O 0,2

%A _Jean-Marc Rebert_, Jul 12 2023