Divisor Function σ(n)

lean4-proofnumber-theoryvisualization
σ(n)=dnd\sigma(n) = \sum_{d \mid n} d

Statement

The divisor function (or sum-of-divisors function) σ(n)\sigma(n) is defined for positive integers nn by

σ(n)=dnd.\sigma(n) = \sum_{d \mid n} d.

More generally, σk(n)=dndk\sigma_k(n) = \sum_{d \mid n} d^k; the case k=1k = 1 is the most classical.

Key property: σ\sigma is multiplicative — for coprime m,nm, n:

gcd(m,n)=1    σ(mn)=σ(m)σ(n).\gcd(m, n) = 1 \implies \sigma(mn) = \sigma(m)\,\sigma(n).

A number nn is perfect if σ(n)=2n\sigma(n) = 2n (equivalently, the sum of proper divisors equals nn).

Visualization

Values of σ(n)\sigma(n) for n=1n = 1 to 2020. Perfect numbers (σ(n)=2n\sigma(n) = 2n) are starred:

nnDivisors of nnσ(n)\sigma(n)Note
111
21, 23
31, 34
41, 2, 47
51, 56
61, 2, 3, 612perfect \star
71, 78
81, 2, 4, 815
91, 3, 913
101, 2, 5, 1018
111, 1112
121, 2, 3, 4, 6, 1228
131, 1314
141, 2, 7, 1424
151, 3, 5, 1524
161, 2, 4, 8, 1631
171, 1718
181, 2, 3, 6, 9, 1839
191, 1920
201, 2, 4, 5, 10, 2042
281, 2, 4, 7, 14, 2856perfect \star

Multiplicativity check: σ(4)=7\sigma(4) = 7, σ(3)=4\sigma(3) = 4, σ(12)=σ(43)=74=28\sigma(12) = \sigma(4 \cdot 3) = 7 \cdot 4 = 28. \checkmark

Proof Sketch

  1. Multiplicativity. For coprime m,nm, n, every divisor of mnmn factors uniquely as d1d2d_1 d_2 with d1md_1 \mid m, d2nd_2 \mid n. Hence dmnd=(d1md1)(d2nd2)=σ(m)σ(n)\sum_{d \mid mn} d = \bigl(\sum_{d_1 \mid m} d_1\bigr)\bigl(\sum_{d_2 \mid n} d_2\bigr) = \sigma(m)\sigma(n).
  2. Prime powers. σ(pk)=1+p+p2++pk=(pk+11)/(p1)\sigma(p^k) = 1 + p + p^2 + \cdots + p^k = (p^{k+1}-1)/(p-1).
  3. General formula. By multiplicativity, for n=piein = \prod p_i^{e_i}: σ(n)=iσ(piei)=ipiei+11pi1\sigma(n) = \prod_i \sigma(p_i^{e_i}) = \prod_i \frac{p_i^{e_i+1}-1}{p_i-1}.
  4. Perfect numbers. Even perfect numbers have the form 2p1(2p1)2^{p-1}(2^p - 1) where 2p12^p - 1 is a Mersenne prime (Euler's theorem).

Connections

σ\sigma is the canonical example of a multiplicative functionMultiplicative Functionsgcd(m,n)=1f(mn)=f(m)f(n)\gcd(m,n)=1 \Rightarrow f(mn)=f(m)f(n)Arithmetic functions that split over coprime inputs: f(mn) = f(m)f(n) when gcd(m,n) = 1Read more →. The Möbius InversionMöbius Inversionf(n)=dnμ(d)g ⁣(nd)f(n) = \sum_{d \mid n} \mu(d)\, g\!\left(\frac{n}{d}\right)If g equals the Dirichlet convolution of f with the constant 1, then f recovers via the Möbius functionRead more → formula expresses σ\sigma as a Dirichlet convolution σ=id1\sigma = \mathrm{id} * \mathbf{1}, connecting it to the theory of Euler's Totient FunctionEuler's Totient Functionaφ(n)1(modn)a^{\varphi(n)} \equiv 1 \pmod{n}φ(n) counts integers up to n coprime to n, and governs modular exponentiationRead more →.

Lean4 Proof

import Mathlib.NumberTheory.ArithmeticFunction.Misc

open ArithmeticFunction in
/-- σ is multiplicative: isMultiplicative_sigma from Mathlib. -/
theorem sigma_multiplicative {k : } :
    IsMultiplicative (σ k) :=
  isMultiplicative_sigma

open ArithmeticFunction in
/-- σ₁(6) = 12: sum of divisors of 6 is 1+2+3+6 = 12.
    We verify via the explicit divisor set and sigma_one_apply. -/
theorem sigma_6 : σ 1 6 = 12 := by
  rw [sigma_one_apply]
  decide

open ArithmeticFunction in
/-- 6 is perfect: σ₁(6) = 2·6. -/
theorem six_is_perfect : σ 1 6 = 2 * 6 := by
  rw [sigma_one_apply]
  decide