%I #53 Oct 22 2024 02:58:03
%S 0,0,1,1,3,3,4,5,5,5,7,7,9,10,10,10,12,13,14,15,15,15,17,17,18,19,19,
%T 20,22,22,23,24,25,25,26,26,27,28,29,29,31,31,33,34,34,35,37,38,38,39,
%U 39,39,41,41,41,42,42,43,45,46,48,49,50,50,51,51,53,54
%N a(n) = n - 1 - pi(2*n-1) + pi(n), where pi is the prime counting function.
%C For n > 1, a(n) is the number of composites in the closed interval [n+1, 2n-1].
%C a(n) is also the number of composites appearing among the largest parts of the partitions of 2n into two distinct parts.
%H N. J. A. Sloane, <a href="/A307912/b307912.txt">Table of n, a(n) for n = 1..20000</a>
%H <a href="/index/Par#part">Index entries for sequences related to partitions</a>
%F a(n) = n - 1 - A060715(n).
%F a(n) = n - 1 - A000720(2*n-1) + A000720(n).
%e a(7) = 4; there are 4 composites in the closed interval [8, 13]: 8, 9, 10 and 12.
%p chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855
%p A307912 := proc(n) chi(2*n-1) - chi(n); end;
%p A := [seq(A307912(n),n=1..120)]; # _N. J. A. Sloane_, Oct 20 2024
%t Table[n - 1 - PrimePi[2 n - 1] + PrimePi[n], {n, 100}]
%o (Python)
%o from sympy import primepi
%o def A307912(n): return n+primepi(n)-primepi((n<<1)-1)-1 # _Chai Wah Wu_, Oct 20 2024
%Y Related sequences:
%Y Primes (p) and composites (c): A000040, A002808, A000720, A065855.
%Y Primes between p(n) and 2*p(n): A063124, A070046; between c(n) and 2*c(n): A376761; between n and 2*n: A035250, A060715, A077463, A108954.
%Y Composites between p(n) and 2*p(n): A246514; between c(n) and 2*c(n): A376760; between n and 2*n: A075084, A307912, A307989, A376759.
%K nonn,easy,changed
%O 1,5
%A _Wesley Ivan Hurt_, May 09 2019