TITLE: How many pairs of primes are there such that $pq < 10^6$
QUESTION [5 upvotes]: I'm trying to implement this function in my program, so I think that I should find that the number of pairs $$(p, q)$$ such that both p, q are prime numbers and: $$p\cdot q < 10^6$$
I'm not really good in number theory, I know that there are $78498$ primes under one million, but I know that only some of those primes form combinations that are less that one million.
Thanks in advance.

REPLY [2 votes]: The number of numbers less than 1000000 with k prime factors are: 
k=1: 78498, k=2: 210035, 3: 250853, 4:198062, 5:124465,6: 68963, 7: 35585, 8: 17572, 9: 8491, 
10: 4016, 11: 1878, 12: 865, 13: 400, 14: 179, 15: 79, 16: 35, 17: 14, 18: 7, 19:  2.  
The number of near-primes $pq\leq 10^6 = 210035.$ 
Basically you have to write a program to count the number of primes in each number and sort through them. The generalized prime number theorem gives a quick estimate which is good for k small compared to $\log_2 n.$