A065855 Number of composites <= n.
0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 27, 27, 28, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 41, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 50, 51, 51, 52, 53
Offset: 1
Examples
Prime(8) = 19 and there are 3 primes between 8 and 19 (endpoints are excluded), namely 11, 13, 17. Hence a(8) = 3.
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..20000 [First 1000 terms from T. D. Noe]
- Ya-Ping Lu and Shu-Fang Deng, Properties of Polytopes Representing Natural Numbers, arXiv:2003.08968 [math.GM], 2020.
Crossrefs
Programs
-
Haskell
a065855 n = a065855_list !! (n-1) a065855_list = scanl1 (+) (map a066247 [1..]) -- Reinhard Zumkeller, Oct 20 2014
-
Maple
A065855 := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # N. J. A. Sloane, Oct 20 2024 a := [seq(A065855(n),n=1..120)];
-
Mathematica
(*gives number of primes < n*) f[n_] := Module[{r, i}, r = 0; i = 1; While[Prime[i] < n, i++ ]; i - 1]; (*gives number of primes between m and n with endpoints excluded*) g[m_, n_] := Module[{r}, r = f[m] - f[n]; If[PrimeQ[n], r = r - 1]; r]; Table[g[Prime[n], n], {n, 1, 1000}] Table[n-PrimePi[n]-1,{n,75}] (* Harvey P. Dale, Jun 14 2011 *) Accumulate[Table[If[CompositeQ[n],1,0],{n,100}]] (* Harvey P. Dale, Sep 24 2016 *)
-
PARI
a(n) = { n - primepi(n) - 1 } \\ Harry J. Smith, Nov 01 2009
-
Python
from sympy import primepi def A065855(n): return 0 if n < 4 else n - primepi(n) - 1 # Chai Wah Wu, Apr 14 2016
Comments