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.

A306863 a(n) is the number of primes between the n-th and (n+1)-st odd composite numbers.

Original entry on oeis.org

2, 2, 1, 0, 2, 0, 1, 2, 1, 0, 1, 0, 2, 0, 1, 2, 0, 1, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0, 0, 0, 0, 0, 1, 1, 0, 2, 0, 0, 0, 2, 0, 1, 0, 1, 1, 0, 1, 0, 2, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 2, 0, 0, 0, 1, 0, 0
Offset: 1

Views

Author

Zhandos Mambetaliyev, Mar 14 2019

Keywords

Examples

			The first few odd composite numbers are 9, 15, 21, 25, 27, 33, 35, 39, 45, 49. Between 9 and 15, there are two primes (11 and 13); between 15 and 21 there are also two primes (17 and 19); between 21 and 25 there is only one prime (23), etc.
		

Crossrefs

Cf. A071904, A000040, A001223 (differences between primes), A164510, A001097.

Programs

  • Mathematica
    Differences@ PrimePi@ Complement[Range[3, #, 2], Prime@ Range[2, PrimePi@ #]] &@ 300 (* Michael De Vlieger, Apr 21 2019 *)
    Differences[PrimePi/@Select[Range[3,301,2],CompositeQ]] (* Harvey P. Dale, Sep 16 2023 *)
  • PARI
    { b=9; for(i=6, 150, if(isprime(2*i-1)==0, print1(primepi(2*i-1)-primepi(b), ", "); b=2*i-1)) }
    
  • Python
    from itertools import count
    from sympy import primepi, isprime
    def A306863(n):
        if n == 1: return 2
        m, k = n, primepi(n) + n + (n>>1)
        while m != k:
            m, k = k, primepi(k) + n + (k>>1)
        return next(c for c in count(0) if not isprime(m+(c<<1)+2)) # Chai Wah Wu, Aug 02 2024