Divisor Functions — d(n), σ(n) & the Divisor Sieve

From the prime factorization, d(n) = Π(aᵢ+1) and σ(n) = Π(1+p+…+p^a). The divisor sieve computes both for all numbers up to N by striding each divisor through its multiples — Σ N/d ≈ N ln N.

step 0

Prime-power blocks of n = 360

d(n) = ?    σ(n) = ?
active prime power contributes (a+1) to d contributes geom. sum to σ

Running product

prime p
exponent a
d ×= (a+1)1
σ ×= 1+…+p^a1

Complexity

OperationTime
Factor n (trial division)O(√n)
d(n) from exponentsO(#primes)
σ(n) from exponentsO(Σ aᵢ)
Press Step. We factor n into prime powers, then fold each block into the product: every prime power multiplies d by (a+1) and σ by (1 + p + … + p^a).
Self-contained visualization. Left tab: the closed forms d(n)=Π(aᵢ+1) and σ(n)=Π(1+p+…+p^a) from the factorization (multiplicativity over coprime prime powers). Right tab: the divisor sieve, whose total work Σ₃≤ₙ N/d ≈ N ln N gives O(N log N). See junior.md, middle.md, and professional.md for derivations and the linear-sieve O(N) variant.