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.