login
A306863
a(n) is the number of primes between the n-th and (n+1)-st odd composite numbers.
1
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,1
LINKS
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
Cf. A071904, A000040, A001223 (differences between primes), A164510, A001097.
Sequence in context: A287407 A153240 A153241 * A334108 A332813 A323077
KEYWORD
nonn
AUTHOR
STATUS
approved