%I #17 Oct 22 2024 02:58:29
%S 0,0,1,2,3,4,4,6,6,6,7,8,9,11,11,11,12,14,14,16,16,16,17,18,19,20,20,
%T 21,22,23,23,25,26,26,27,27,27,29,30,30,31,32,33,35,35,36,37,39,39,40,
%U 40,40,41,42,42,43,43,44,45,47,48,50,51,51,52,52,53,55
%N a(n) = n - pi(2*n) + pi(n-1), where pi is the prime counting function.
%C a(n) is the number of composites in the closed interval [n, 2n-1].
%C a(n) is also the number of composites among the largest parts of the partitions of 2n into two parts.
%H N. J. A. Sloane, <a href="/A307989/b307989.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 - A035250(n).
%F a(n) = n - A000720(2*n) + A000720(n-1).
%e a(7) = 4; There are 7 partitions of 2*7 = 14 into two parts (13,1), (12,2), (11,3), (10,4), (9,5), (8,6), (7,7). Among the largest parts 12, 10, 9 and 8 are composite, so a(7) = 4.
%p chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855
%p A307989 := proc(n) chi(2*n-1) - chi(n-1); end;
%p a := [seq(A307989(n),n=1..120)];
%t Table[n - PrimePi[2 n] + PrimePi[n - 1], {n, 100}]
%o (Python)
%o from sympy import primepi
%o def A307989(n): return n+primepi(n-1)-primepi(n<<1) # _Chai Wah Wu_, Oct 20 2024
%Y Cf. A000720, A035250.
%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,4
%A _Wesley Ivan Hurt_, May 09 2019