Sum of divisors calculator
The divisors of 12 add up to 28: 1 + 2 + 3 + 4 + 6 + 12. Enter any positive whole number up to one trillion and get this exact sum with the prime factors used to work it out. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 12
- Sigma
- 28
The divisor function sigma(n) adds every positive divisor of a positive integer n, including 1 and n itself. Perfect numbers, abundant numbers, aliquot sequences, and many number-theory checks all depend on this total. This capability factors n with trial division, applies the multiplicative formula for the sum-of-divisors function, and returns both sigma(n) and the prime factorization used to compute it—deterministic, offline, and free to try in your browser.
What sigma(n) means and why factorization is enough
For a positive integer n, sigma(n) is the sum of all positive integers that divide n exactly. For example, the positive divisors of 12 are 1, 2, 3, 4, 6, and 12, so sigma(12) equals 28. Listing every divisor by scanning up to n works for tiny values but becomes wasteful as n grows.
Number theory supplies a closed multiplicative form: if the prime factorization of n is p1^a1 times p2^a2 times … times pk^ak, then sigma(n) equals the product over i of (1 + pi + pi^2 + … + pi^ai), which is also (pi^(ai+1) − 1) / (pi − 1). That identity is exact for every n greater than or equal to 1; in particular sigma(1) is 1 with an empty product.
This calculator never samples random candidates or approximates: it factors n once, multiplies the geometric series for each prime power, and returns the integer total together with the factors it found so you can audit the steps.
Perfect, deficient, and abundant numbers in practice
Comparing sigma(n) to 2n classifies n: if sigma(n) equals 2n the number is perfect (its proper divisors sum to itself); if sigma(n) is less than 2n it is deficient; if greater, abundant. Six is the smallest perfect number because sigma(6) is 12. Twenty-eight is the next classic perfect example.
Abundant numbers such as 12 (sigma 28) and 18 (sigma 39) appear in aliquot-sequence research and recreational number theory. Keep n within the published limit so trial division stays interactive; for cryptographic-size integers you need a dedicated multiprecision factoring stack, not this lightweight parse capability.
What you can do with it
Classify perfect, deficient, and abundant numbers
Compute sigma(n) and compare it with 2n to label each integer in a homework set or research table without hand-listing divisors.
Verify factorization-based homework and contests
Students and contestants can check that their prime factorization yields the correct divisor sum before submitting proofs or programming solutions.
FAQ
What is the sum of divisors of n?
It is sigma(n): the sum of every positive divisor of n, including 1 and n. For 12 the divisors are 1, 2, 3, 4, 6, and 12, so the sum is 28.
How does this calculator compute sigma(n)?
It factors n with trial division and multiplies the geometric series (1 + p + … + p^a) for each prime power p^a in the factorization—the standard multiplicative formula.
Is the sum of divisors calculator free?
The browser tool is free and runs locally.
Does the response include the prime factors?
Yes. Alongside sigma you receive factors as prime/exponent pairs so you can verify the product formula or continue with related divisor counts.
How can the sum of divisors tell me if a number is perfect?
Compare the sum with twice the number. If they are equal, the number is perfect, as with 6, whose divisors add up to 12. If the sum is smaller it is deficient, and if larger, as with 12 and its 28, it is abundant.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/divisor-sum \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":12}'const res = await fetch("https://api.kit.forhosting.com/numth/divisor-sum", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 12
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/divisor-sum",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 12
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/divisor-sum", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":12}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":12}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/divisor-sum", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 12
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.divisor_sum",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 1000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How to call the API and what comes back
On success the response includes n as accepted, sigma as the full divisor sum, and factors as an ordered list of objects each with prime and exponent. Use it from scripts, homework pipelines, CTF write-ups, or any workflow that needs a reproducible sigma(n) without installing a computer-algebra system. Send a JSON body with a single required field n—a positive whole number at least 1 and at most one trillion (10^12). Aliases number and value are accepted for the same field. Failed validation—missing n, a non-integer, a value below 1, or a value above the limit—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request (unit item with zero marginal unit price).
Perfect, deficient, and abundant numbers in practice
Because this endpoint returns both the sum and the factorization, you can also derive the number of divisors as the product of (exponent + 1) for each prime power, or build the full divisor list offline from the factors when you need it for teaching or debugging.
Integration use cases
Build aliquot or friend-number pipelines
Scripts that walk aliquot sequences need a reliable sigma step; call this API (or the free browser core) as a deterministic building block.
Technical questions
What inputs are rejected?
Missing n, non-integers, values below 1, and values above 10^12 return invalid_input. Those failures are not charged.