A008508 Number of odd primes less than n-th odd composite number.
3, 5, 7, 8, 8, 10, 10, 11, 13, 14, 14, 15, 15, 17, 17, 18, 20, 20, 21, 22, 22, 23, 23, 23, 24, 26, 28, 29, 29, 29, 29, 29, 29, 30, 31, 31, 33, 33, 33, 33, 35, 35, 36, 36, 37, 38, 38, 39, 39, 41, 41, 41, 41, 43, 45, 45, 45, 45, 45, 46
Offset: 1
Keywords
Examples
The first odd composite is 9, and there are 4 primes below: 2, 3, 5, and 7; so there are 3 odd primes, hence a(1)=3.
Links
- Antti Karttunen, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
PrimePi[#] - 1 & /@ Select[Range@ 213, CompositeQ@ # && OddQ@ # &] (* Michael De Vlieger, Apr 17 2015 *)
-
PARI
lista(nn) = {forcomposite (n=1, nn, if (n % 2, print1(primepi(n)-1, ", ")););} \\ Michel Marcus, Apr 18 2015
-
Python
from sympy import primepi def A008508(n): if n == 1: return 3 m, k = n, (r:=primepi(n)) + n + (n>>1) while m != k: m, k = k, (r:=primepi(k)) + n + (k>>1) return r-1 # Chai Wah Wu, Aug 01 2024