Note that this question contains some spoilers.
A solution for problem #12 states that
"Number of divisors (including 1 and the number itself) can be calculated taking one element from prime (and power) divisors."
The (python) code that it has doing this is num_factors = lambda x: mul((exp+1) for (base, exp) in factorize(x))
(where mul()
is reduce(operator.mul, ...)
.)
It doesn't state how factorize
is defined, and I'm having trouble understanding how it works. How does it tell you the number of factors of the number?