The prime-counting function returns the number of prime numbers less than or equal to . The prime number theorem gives the asymptotic behaviour .

We shall call a number *semiprime* if it is the product of two primes. Let denote the semiprime-counting function. What is the asymptotic behaviour of ? I claim that

**Edit (17 September 2016) **Based on experiments in Mathematica, the above seems to be a lower bound, while an upper bound is given by

I obtain these by the following heuristic, probabilistic argument. The probability that a random integer chosen between 1 and is ; loosely, this means that the probability of a randomly chosen large number is approximately . Similarly, is the probability that a randomly-chosen is semiprime.

An exact formula for is

The sum over is trivially . Hence

We split the sum at into two parts, and assume that the first part is dominated by the second. In the second part, is large and we invoke and approximate the sum as an integral, to get

Evaluating the integral and keeping only the highest-order terms, we get the desired formula.

The semiprime-counting function can be implemented in Mathematica by

SemiprimeQ[n_] := SemiprimeQ[n] = Module[{f}, f = FactorInteger[n]; ( ((Length[f] == 2) && (Total[Last /@ f] == 2)) || ((Length[f] == 1) && f[[1]][[2]] == 2) ) ]; w[n_] := w[n] = Length[Select[Range[n], SemiprimeQ]]

(where we memoise the results to speed things up). The following code produces a graph showing the validity of these approximation:

W1[n_] := n/Log[n] Log[Log[n]]; W2[n_] := n/Log[n] Log[Log[n]/Log[2]]; nn = 150000; nj = 500; Show[ ListPlot[Table[{n, w[n]/W1[n]}, {n, 1, nn, nj}], PlotStyle -> Red], ListPlot[Table[{n, w[n]/W2[n]}, {n, 1, nn, nj}], PlotStyle -> Green] ]