While experimenting with different solutions to a little programming exercise, I generated an array with the products of all two three-digit numbers (i.e. 100 to 999). Since I wanted to process those products in descending order, I then sorted the array and then looked for the first element matching a certain predicate.
However, since the first matching element is usually near the beginning of the array, generating all numbers and then sorting all of them is quite wasteful. Instead, I wonder: is it maybe possible to generate the products incrementally? The ten largest products of two three-digit numbers are
998001 = 999 * 999
997002 = 998 * 999
996004 = 998 * 998
996003 = 997 * 999
995006 = 997 * 998
995004 = 996 * 999
994009 = 997 * 997
994008 = 996 * 998
994005 = 995 * 999
993012 = 996 * 997
I tried to find a pattern in the factor pairs, but couldn't spot anything. I suspect there is some algorithm for getting the products in descending order without having to compute all the products in advance though - or maybe there isn't?
For each of the 999 possible first factors, construct an object that will produce the multiples of that factor on demand starting with the highest one. Each object has a primitive to ask it what the next number to produce is (without updating it), and one to move to the next number.
Maintain a priority queue of these generator objects, arranged by which one has the largest "next product". Once you consume a result, remove the front of the queue, and reinsert it after you update it to move to the next number.
Naively (and abusing the notation horribly!), setting up all this takes $O(999)$ time once and for all, and afterwards each successive product can be retrieved in time $O(\log 999)$.
You can get rid of the initial set-up time by only creating the generator for multiples of $n-1$ after the first multiple of $n$ has been consumed (since it can't possibly be relevant until that happens anyway).