How a Divisor Function Calculator Finds sigma(n) and tau(n) from Factors
About the Author

A divisor function calculator gets two answers out of one factorization. Give it 60, it writes 60 = 2² · 3 · 5, and from those three exponents alone it reports τ(60) = 12 divisors adding up to σ(60) = 168 — without ever checking whether 7 divides 60, or 8, or 59.
That trade is the entire subject. Factor once, and every divisor question becomes a product of small terms. Skip the factorization and you are back to testing candidates one at a time, which is fine for 60 and hopeless for a quintillion: 10¹⁸ = 2¹⁸ · 5¹⁸ has exactly 361 divisors, and finding them by division would take a billion tests to reach √n.
Five Functions, One Factorization — Which One Answers Your Question
Half the wrong answers in this topic are the right calculation applied to the wrong function. Here is the whole family, evaluated on n = 60 so you can see them side by side.
| You want | Function | Product rule | n = 60 |
|---|---|---|---|
| How many divisors | τ(n) = d(n) = σ₀(n) | Π (aᵢ + 1) | 12 |
| Sum of all divisors | σ(n) = σ₁(n) | Π (p^(a+1) − 1)/(p − 1) | 168 |
| Sum of proper divisors | s(n) = σ(n) − n | subtract n at the end | 108 |
| Sum of squared divisors | σ₂(n) | Π (p^(2a+2) − 1)/(p² − 1) | 5,460 |
| Count of coprimes below n | φ(n) | Π p^(a−1)(p − 1) | 16 |
Two traps live in that table. The first is the phrase “sum of divisors”, which some courses use for σ(n) = 168 and others for the proper-divisor sum s(n) = 108. Perfect-number problems always mean the second; formula sheets almost always mean the first. The gap is exactly n, so a 60-off answer is nearly always this and not an arithmetic slip.
The second is φ(n), which counts numbers coprime to n rather than numbers dividing n. It shares the same multiplicative machinery and nothing else — the Euler phi calculator handles that one. If a question mentions fractions in lowest terms or modular inverses, it wants φ; if it mentions factors, remainders or divisibility, it wants τ or σ.
Exponents Plus One: Where τ(n) Comes From
Write n = 2³ · 3² · 5 — that is 360. Any divisor of 360 is built by choosing how many 2s to take (0, 1, 2 or 3), how many 3s (0, 1 or 2) and how many 5s (0 or 1). The choices are independent, so multiply them: 4 × 3 × 2 = 24 divisors. That is the whole derivation, and it is why the rule is exponents plus one rather than exponents.
Run it on the neighbors and the spikiness of divisor counts becomes obvious. 360 has 24 divisors; 361 = 19² has 3; 362 = 2 · 181 has 4. Nothing about a number’s size predicts its divisor count — only its prime factorization does. A factor calculator that lists divisors one by one is doing 360 units of work to learn what the exponents give away in three multiplications.
One consequence is worth memorizing: τ(n) is odd exactly when n is a perfect square. Divisors normally pair up as d and n/d, so they come in twos; only when d = n/d does a divisor stand alone. 36 has 9 divisors, 1024 has 11, and any number with an odd divisor count is a square, no exceptions.
Inside a Divisor Function Calculator: One Geometric Series Per Prime
σ works the same way, except each prime contributes a sum instead of a count. All the powers of 2 dividing 360 are 1, 2, 4, 8; all the powers of 3 are 1, 3, 9; the powers of 5 are 1, 5. Multiply out (1+2+4+8)(1+3+9)(1+5) and every term of the expansion is a distinct divisor of 360, each appearing once. So:
σ(360) = 15 × 13 × 6 = 1,170
s(360) = 1,170 − 360 = 810
Each bracket is a geometric series, so it has the closed form σ(pᵃ) = (pa+1 − 1)/(p − 1). For a bigger case take 5040 = 2⁴ · 3² · 5 · 7:
τ(5040) = 5 × 3 × 2 × 2 = 60
σ(5040) = 31 × 13 × 6 × 8 = 19,344
Sixty divisors, and not one of them was listed. Now the caveat that catches people: σ is multiplicative only across coprime pieces. σ(4) = 1 + 2 + 4 = 7, but σ(2) · σ(2) = 3 × 3 = 9. Splitting 4 into 2 × 2 double-counts, because the two halves share a prime. Split by prime powers — 360 into 8, 9 and 5, never into 6 and 60 — and the rule holds every time. When you need to check whether two numbers share a factor before applying it, a GCF calculator settles it in one step.
The 2n Line: Deficient, Perfect, Abundant
Compare σ(n) with 2n and every integer sorts into one of three classes. The reason 2n is the threshold is that σ(n) already includes n itself, so σ(n) = 2n means the other divisors rebuild n exactly.
| n | σ(n) | σ(n)/n | Class |
|---|---|---|---|
| 1024 = 2¹⁰ | 2,047 | 1.9990 | deficient by 1 |
| 28 | 56 | 2.0000 | perfect |
| 945 = 3³·5·7 | 1,920 | 2.0317 | smallest odd abundant |
| 360 | 1,170 | 3.2500 | abundant |
| 5040 | 19,344 | 3.8380 | strongly abundant |
Powers of two are the near-misses of number theory: σ(2ᵏ) = 2k+1 − 1, one short of 2n every single time. 12 is the smallest abundant number, and odd abundant numbers are rare enough that the first is 945 — everyone guesses smaller.
Perfect numbers come from a two-line argument. If 2ᵖ − 1 is prime, then n = 2p−1(2ᵖ − 1) has σ(n) = (2ᵖ − 1) · 2ᵖ = 2n, because the two pieces are coprime. That is Euclid’s construction; Euler proved every even perfect number looks like this. With p = 13 you get 2¹² · 8191 = 33,550,336, and the search for more is the same search that hunts Mersenne primes. Whether an odd perfect number exists is still open after 2,000 years — it has been ruled out below 10¹⁵⁰⁰.
Feed n and s(n) back through the same function and you get amicable pairs: s(220) = 284 and s(284) = 220, so those two numbers point at each other forever. The amicable numbers calculator chases longer chains too.
Divisor Counts Jump Around; Their Averages Don’t
Individual values of τ are erratic — 60 has 12 divisors and 61 has 2 — but the running average is so regular you can predict it. The average number of divisors of the integers up to N is about ln N + 2γ − 1, where γ = 0.5772 is the Euler–Mascheroni constant. At N = 200,000 that predicts 12.361 divisors per number. Summed directly, the true figure is 12.361. Three decimal places, from a formula with no divisors in it at all.
σ behaves the same way: the abundancy ratio σ(n)/n bounces between 1.0 for primes and 6 or more for extreme cases, yet its long-run average converges to π²/6 ≈ 1.6449. So a randomly chosen integer has, on average, divisors summing to about 1.64 times itself — which also explains why abundant numbers make up roughly a quarter of all integers rather than half.
The record-holders form their own sequence. These are the numbers with more divisors than anything smaller, and the pattern in their factorizations is the reason 60 minutes, 360 degrees and 5,040 crop up in every measurement system ever designed.
| n | Factorization | τ(n) |
|---|---|---|
| 12 | 2² · 3 | 6 |
| 60 | 2² · 3 · 5 | 12 |
| 360 | 2³ · 3² · 5 | 24 |
| 840 | 2³ · 3 · 5 · 7 | 32 |
| 2,520 | 2³ · 3² · 5 · 7 | 48 |
| 5,040 | 2⁴ · 3² · 5 · 7 | 60 |
Notice what they never do: jump to a large prime. Exponents stay in descending order across ascending primes, because moving a unit of exponent to a smaller prime buys the same divisor count for a smaller n. That is also the fastest way to sanity-check a divisibility claim about a “highly composite” number: if its factorization has a big prime with a small exponent, it is not a record-holder.
Two Different Things Called Sigma, Two Called Tau
Searching for a “sigma calculator” turns up two unrelated tools, and the collision is worth naming. σ(n) with a single integer argument is the divisor function on this page. The capital Σ with an index underneath is summation notation, an instruction to add a sequence — that is a sigma notation calculator, and it has nothing to do with divisors. Statistics adds a third σ for standard deviation.
τ has the same problem. Here τ(n) counts divisors; in modular-forms work τ(n) is Ramanujan’s tau function, whose values run τ(2) = −24 and τ(3) = 252. If a source quotes a negative tau, you are in the wrong subject. Writers who want to avoid the clash use d(n) for the divisor count, which is why you will see d(n), τ(n) and σ₀(n) all meaning the same thing.
The subscript notation is the one that generalizes. σₖ(n) sums the k-th powers of the divisors, so σ₀ counts them (every divisor to the power zero is 1) and σ₁ adds them. The identity that ties the family together is Σ σₖ(n)/nˢ = ζ(s)ζ(s − k), which is why divisor functions turn up all over analytic number theory rather than staying in the exercises.
Four Ways the Formula Gets Misused
Multiplying the exponents instead of the exponents plus one. For 360 = 2³ · 3² · 5 that gives 3 × 2 × 1 = 6 rather than 24. The tell is that the wrong answer never counts 1 or n — those are precisely the choices you delete when you drop the +1.
Applying multiplicativity to a non-coprime split. σ(12) is σ(4) · σ(3) = 7 × 4 = 28, not σ(2) · σ(6) = 3 × 12 = 36. Only splits into powers of distinct primes are safe.
Forgetting that n divides itself. Every perfect-number definition, aliquot sequence and amicable-pair check runs on s(n) = σ(n) − n. Every product formula produces σ(n). Mixing them is the single most common source of “my answer is off by exactly n”.
Trial division past √n. Divisors pair as d ↔ n/d, so scanning to the square root finds all of them: for 10¹⁸ that is 10⁹ tests instead of 10¹⁸. Factoring first beats both — the tool above reaches 963,761,198,400 and its 6,720 divisors in a couple of milliseconds.
Three checks catch most errors before they propagate. τ(n) = 2 if and only if n is prime. τ(n) is odd if and only if n is a perfect square. And σ(n) is odd only when n is a square or twice a square — σ(18) = 39 is odd because 18 = 2 · 3², while σ(20) = 42 is even. Any result that fails one of these is wrong before you check the arithmetic.
For the raw sequences, OEIS A000005 lists τ(n) and A000203 lists σ(n) for thousands of terms, and the Wikipedia divisor function article carries the full Dirichlet-series statements and the growth bounds.



