How to get all the factors of a number using its prime factorization? For example, I have the number $420$. This can be broken down into its prime factorization of $$2^2 \times3^1\times5^1\times7^1 = 420 $$
Using $$\prod_{i=1}^r (a_r + 1)$$ where $a$ is the magnitude of the power a prime factor is raised by and $r$ is the number of prime factors. I get $24$ possible factors.
Is there an easy way to iterate through all those $4$ factors to obtain all $24$? I know this can be easily done using a table with numbers with only $2$ factors. But, as this one has $4$ I obviously can't implement the table method. So any general solution to do this? Thanks!

Expand the following expression:
$$(2^0+2^1+2^2)(3^0+3^1)(5^0+5^1)(7^0+7^1)$$
Each combination of four choices (e.g. $2^2, 3^1, 5^0, 7^1$, whose product is $2^23^15^07^1=84$) gives a distinct factor of $420$.
