Count and sum divisors from exponents
View each divisor as an independent choice of exponents.
Understand the idea
If n = p₁^e₁ ... pₖ^eₖ, each divisor chooses exponent 0 through eᵢ for each prime. The divisor count τ(n) is the product of (eᵢ + 1). Expanding the product of (1 + pᵢ + ... + pᵢ^eᵢ) gives the divisor sum σ(n).
Trace a small example
For 12 = 2² × 3, τ(12) = 3 × 2 = 6 and σ(12) = (1 + 2 + 4)(1 + 3) = 28. Its proper-divisor sum is 16. A perfect square has all even exponents; a square divisor chooses only even exponents.
Conditions and cost
For n = 1, both count and sum are 1 by the empty-product rule. Build integer powers iteratively, not with floating-point pow. Bound every intermediate product and sum, not only n.
How many divisors does 72 = 2³ × 3² have?
Turn the idea into code
How many square divisors does 72 have?
Give me a hint
Each prime can use exponent 0 or 2.
Show the explained solution
There are 4: 1, 4, 9, 36.
Your notes
Mark complete when you can explain it yourself.