Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #45 Dec 24 2022 11:12:20
%S 2,8,13,21,32,38,46,60,85,74,102,111
%N a(n) is the smallest k such that there are exactly n primes between k*(k-1) and k^2 and exactly n primes between k^2 and k*(k+1), or 0 if no such k exists.
%C Does k exist for every n?
%C a(15)=135, a(17)=154. - _Chai Wah Wu_, Apr 16 2021
%C If they are nonzero, a(13)-a(14), a(16), a(18)-a(19), a(22), a(25)-a(26), a(33)-a(35) > 710000; a(20) = 200, a(21) = 192, a(23) = 258, a(24) = 277, a(27) = 317, a(28) = 283, a(29) = 314, a(30) = 352, a(31) = 365, a(32) = 461. - _J.W.L. (Jan) Eerland_, Dec 21 2022
%C A stronger statement can be made regarding the terms listed above that are either 0 or > 710000: No two primes < A002386(80) = 18361375334787046697 differ by more than A005250(80) = 1550, and sqrt(18361375334787046697) = 4285017541.946..., so for every k in the interval [710000, 4285017541] there are more than 458 primes in each of the two intervals [k*(k-1), k^2] and [k^2, k*(k+1)], so every term a(n) with n <= 35 that is either 0 or > 710000 is necessarily either 0 or > 4285017541 (with a(n) = 0 looking nearly certain). - _Jon E. Schoenfield_, Dec 23 2022
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Oppermann%27s_conjecture">Oppermann's conjecture</a>.
%e For n = 6: 38*(38-1) = 1406, 38^2 = 1444 and 38*(38+1) = 1482. A000720(1444) - A000720(1406) = 6 and A000720(1482) - A000720(1444) = 6. Since 38 is the smallest k where the number of primes in both intervals is 6, a(6) = 38.
%t Table[SelectFirst[Range[10^3], And[PrimePi[#^2] - PrimePi[# (# - 1)] == n, PrimePi[# (# + 1)] - PrimePi[#^2] == n] &], {n, 30}] /. k_ /; MissingQ@ k -> 0 (* _Michael De Vlieger_, Apr 09 2016, Version 10.2 *)
%o (PARI) a(n) = my(k=1); while((primepi(k^2)-primepi(k*(k-1)))!=n || (primepi(k*(k+1))-primepi(k^2))!=n, k++); k
%K nonn,more
%O 1,1
%A _Felix Fröhlich_, Apr 07 2016
%E Escape clause added to definition by _Chai Wah Wu_, Apr 17 2021