A306863 a(n) is the number of primes between the n-th and (n+1)-st odd composite numbers.
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
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.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
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