How many numbers $ N \le 10^{10}$ are the product of $3$ distinct primes? How many numbers $ N \le10^{10}$ are the product of $3$ distinct primes? I can realistically calculate any $\pi(n), n < 10^{15} $ but I don't think it's possible to list all primes $>10^8$ in memory. The limits aren't hard but are approximations. Obviously $\binom{\pi(10^{10})}{3}$ won't work, as that produces products way above $10^{10}$. I suspect a recursive solution may work, but I do not have experience in those methods, and three for loops is much too slow. Ideally, the solution is sublinear in time complexity and can be extended to $10^{11}, 10^{12}, 10^{13}, 10^{14}, ...$ 
Edit: A modified Sieve of Eratosthenes method similar to this answer may work, with three primes instead of one, but it requires $O(N)$ memory, which is not realistic.  
 A: You'll need a list of primes out to around $71{,}000$.  This is because if $n\lt10^{10}$ is a product of three distinct primes, say $n=pqr$ with $p\lt q\lt r$, then $q\lt\sqrt{10^{10}/p}\le10^5/\sqrt2\approx70{,}710.678$.  Note also that $p\lt\sqrt[3]{10^{10}}\approx2154.43$, so there is a fairly straightforward brute-force algorithm that seems practical, at least for the specific number, $10^{10}$:
For each prime $p$ between $2$ and $2154$, consider the primes $q$ between $p$ and $10^5/\sqrt p$.  For each of these, compute $\pi(\lfloor10^{10}/pq\rfloor)-\pi(q)$, which counts the number of available primes $r$ that are greater than $q$.  There are only a few hundred primes $p$ and, for most of these, only a few thousand primes $q$, so the total number of times the $\pi$ function needs to be evaluated is almost certainly less than a million, which seems reasonable to ask a computer to do.  A more careful analysis could possibly shave off another order of magnitude or so.
In sum, we can write the function the OP is after as
$$\pi_3(N)=\sum_{2\le p\le\sqrt[3]{N}}\left(\sum_{p\lt q\le\sqrt{N/p}}\left(\pi(\lfloor N/pq\rfloor)-\pi(q) \right)\right)$$
where the nested sums are understood to run over primes in the given ranges.  The total number of summands is (substantially) less than $N^{1/3}N^{1/2}=N^{5/6}$.  I'd be happy to see an approach that does better.
