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”).
%I #33 Jul 01 2021 06:24:57
%S 2,6,10,5,3,7,5,3,5,5,7,4,11,3,5,5,7,3,4,3,7,4,5,5,5,6,6,9,3,6,8,4,6,
%T 5,7,5,5,6,5,5,7,4,9,6,4,10,3,3,4,4,7,4,6,4,5,5,4,5,4,8,6,7,7,5,10,6,
%U 3,3,6,4,4,4,4,4,4,9,8,6,6,6,3,5,6,5,6,5
%N a(n) is the smallest k > 1 such that there are more primes in the interval [(k-1)*n + 1, k*n] than there are in the interval [(k-2)*n + 1, (k-1)*n].
%C a(519) is a noteworthy record high value; a(n) < 13 for all n < 519, and a(n) < 19 for all n < 9363 except that a(519)=19.
%H Jon E. Schoenfield, <a href="/A342068/b342068.txt">Table of n, a(n) for n = 1..10000</a>
%e The 1st 100 positive integers, 1..100, include 25 primes;
%e the 2nd 100 positive integers, 101..200, include 21 primes;
%e the 3rd 100 positive integers, 201..300, include 16 primes;
%e the 4th 100 positive integers, 301..400, include 16 primes;
%e the 5th 100 positive integers, 401..500, include 17 primes.
%e The sequence 25, 21, 16, 16, 17, is nonincreasing until we reach the 5th term, 17, so a(100) = 5.
%e Considering the positive integers in consecutive intervals of length 519, instead (i.e., [1,519], [2,1038], [3,1557], ...) and counting the primes in each interval, we get a sequence that is nonincreasing until we reach the 19th term, since the 19th interval, [9343,9861], contains more primes than does the 18th, so a(519)=19.
%p a:= proc(n) uses numtheory; local i, j, k; i:= n;
%p for k do j:= pi(k*n)-pi((k-1)*n);
%p if j>i then break else i:=j fi
%p od; k
%p end:
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Mar 21 2021
%t a[n_] := Module[{i = n, j, k},
%t For[k = 1, True, k++, j = PrimePi[k*n] - PrimePi[(k-1)*n];
%t If[j > i, Break[], i = j]]; k];
%t Array[a, 100] (* _Jean-François Alcover_, Jul 01 2021, after _Alois P. Heinz_ *)
%o (Python)
%o from sympy import primepi
%o def A342068(n):
%o k, a, b, c = 2,0,primepi(n),primepi(2*n)
%o while a+c <= 2*b:
%o k += 1
%o a, b, c = b, c, primepi(k*n)
%o return k # _Chai Wah Wu_, Mar 25 2021
%Y Cf. A000040, A342069, A342070, A342071, A342839, A342852.
%K nonn
%O 1,1
%A _Jon E. Schoenfield_, Mar 21 2021