τ(n) counts divisors, σ(n) sums them — both computable straight from a prime factorization, no listing required.
Both divisor functions below are multiplicative: if gcd(a,b)=1, thenf(ab)=f(a)f(b). That property is what lets you compute them prime-power by prime-power and multiply the results, rather than examining every divisor individually.
Number of divisors, τ(n)
For n=p1e1⋯pkek:
τ(n)=(e1+1)(e2+1)⋯(ek+1)
Sum of divisors, σ(n)
Each prime’s contribution is a geometric series, summed over its powers from 0 to ei:
σ(n)=i∏(1+pi+pi2+⋯+piei)=i∏pi−1piei+1−1
Worked example
Problem: Find τ(360) and σ(360), given 360=23⋅32⋅5.
Solution:
τ(360)=(3+1)(2+1)(1+1)=4×3×2=24
σ(360)=(1+2+4+8)(1+3+9)(1+5)=15×13×6=1170
Practice problems
1.Find τ(100), given 100=22×52.
2.Find σ(28), given 28=22×7, and check whether 28 is a “perfect number” (σ(n)=2n).