login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A243906
(Number of semiprimes <= n) - (number of primes <= n).
4
0, -1, -2, -1, -2, -1, -2, -2, -1, 0, -1, -1, -2, -1, 0, 0, -1, -1, -2, -2, -1, 0, -1, -1, 0, 1, 1, 1, 0, 0, -1, -1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3, 4, 5, 4, 4, 3, 4, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 3, 4, 4, 4, 5, 5, 4, 4, 4, 5, 4, 4, 5, 6, 7, 7, 6, 6, 7, 7, 8
OFFSET
1,3
COMMENTS
We know from the asymptotic formulas (see Landau) that the sequence is almost always positive.
REFERENCES
E. Landau, Handbuch der Lehre von der Verteilung der Primzahlen, vol. 1, Teubner, Leipzig, 1909; third edition : Chelsea, New York (1974).
LINKS
FORMULA
a(n) = A072000(n) - A000720(n). - Michel Marcus, Dec 20 2022
MAPLE
g:= proc(n) if isprime(n) then -1 elif numtheory:-bigomega(n) = 2 then 1 else 0 fi end proc:
ListTools:-PartialSums(map(g, [$1..100])); # Robert Israel, Dec 20 2022
MATHEMATICA
Accumulate[Table[Which[PrimeQ[n], -1, PrimeOmega[n]==2, 1, True, 0], {n, 1000}]] (* Harvey P. Dale, Jun 15 2014 *)
PROG
(PARI) a(n) = #select(x->(bigomega(x) == 2), [1..n]) - primepi(n); \\ Michel Marcus, Dec 20 2022
(Python)
from math import isqrt
from sympy import prime, primepi
def A243906(n): return int(sum(primepi(n//prime(k))-k+1 for k in range(1, primepi(isqrt(n))+1)))-primepi(n) # Chai Wah Wu, Jul 23 2024
CROSSREFS
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Jun 14 2014
STATUS
approved