Generating integers in ascending order using a set of prime numbers

Removing a number and reinserting all its multiples (by the primes in the set) into a priority queue is wrong (in the sense of the question) – i.e. it produces correct sequence but inefficiently so. It is inefficient in two ways – first, it overproduces the sequence; second, each PriorityQueue operation incurs extra cost (the … Read more