OFFSET
1,3
COMMENTS
The number of composite numbers <= n is n less the number of primes less 1.
The sequence is nondecreasing.
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..20000
FORMULA
a(n) = n - pi(2n) + pi(n-1) + 1, for n>1.
EXAMPLE
a(8) = 7: the composite numbers are 8,9,10,12,14,15 and 16.
MAPLE
chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855
A075084 := proc(n) chi(2*n) - chi(n-1); end;
a := [seq(A075084(n), n=1..120)]; # N. J. A. Sloane, Oct 20 2024
MATHEMATICA
Table[n - PrimePi[2n] + PrimePi[n - 1] + 1, {n, 2, 75}]
PROG
(Python)
from sympy import primepi
def A075084(n): return n+primepi(n-1)-primepi(n<<1)+1 if n>1 else 0 # Chai Wah Wu, Oct 20 2024
(PARI) a(n) = if (n>1, n - primepi(2*n) + primepi(n-1) + 1, 0); \\ Michel Marcus, Oct 21 2024
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Amarnath Murthy, Sep 11 2002
EXTENSIONS
Edited by Robert G. Wilson v, Sep 12 2002
Definition clarified by N. J. A. Sloane, Oct 20 2024
STATUS
approved