cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A008508 Number of odd primes less than n-th odd composite number.

Original entry on oeis.org

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

Views

Author

Gary Findley (chfindley(AT)alpha.nlu.edu), Mar 15 1996

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.
		

Crossrefs

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

Formula

From Antti Karttunen, Apr 17 2015: (Start)
a(n) = A000720(A071904(n)) - 1 (by the definition).
a(n) = A053726(n) - n - 1.
(End)