How to know what "fastest" mean?
(a) fastest to execute in production mode
(b) fastest to prepare data (e.g. calculate a lookup table)
(c) fastest to develop
Assuming you aim for (a) and that you can spend any amount of time to develop it (i.e. (b) and (c)) and assuming you have sufficient storage space with adequate access speed, I would go for
1) during development, produce a lookup table for all 10^9 numbers ;-)
1.1) calculate all prime factors for a given number
1.2) produce all combinations of the prime factors to produce all factors
2) in the production, use that lookup table
E.g. for
n = 63
1) prime factors:
3 x 3 x 7
2) combinations:
(3) x (3) x (7) = 3 x 3 x 7
(3 x 3) x (7) = 9 x 7
(3) x (3 x 7) = 3 x 21
Now you can think of space optimizations, but this will always go on the cost of execution speed. E.g. move 1.2 to production mode, or compress the table (arrange the table as a tree or partition and compress and only deflate the needed part, etc.), ...
Cheers
Andi