Casting out nines check
Casting out nines checks a sum or product in seconds: a claimed total of 579 leaves remainder 3 mod 9, the same as its addends’ remainders 6 and 6 combined, so the check passes. A mismatch proves the answer wrong. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Operands
- 123, 456
- Claimed
- 579
- Operation
- Sum
- Operand residues
- 6, 6
- Combined residue
- 3
- Claimed residue
- 3
- Check
- casting_out_nines
Casting out nines is a classical arithmetic check that uses congruence modulo nine to catch mistakes in addition and multiplication without redoing every digit by hand. Given two or more integer operands, a claimed sum or product, and an operation flag, this capability reduces each number to its residue class modulo nine, combines those residues the same way the original operation would, and compares the result with the residue of the claim. When the two sides disagree, the claimed answer is certainly wrong. When they agree, the claim is only consistent with modular arithmetic: a transposition or an error of a multiple of nine can still hide.
What casting out nines means and why mod 9 works
Every integer is congruent to the sum of its decimal digits modulo nine, because ten is congruent to one modulo nine and higher powers of ten collapse the same way. Repeating the digit sum until a single digit remains produces the digital root, which matches the residue modulo nine except that multiples of nine map to nine rather than zero when the number is nonzero. Casting out nines uses that congruence as a checksum for arithmetic.
If you add several numbers, the residue of the true total must equal the sum of the residues of the addends, taken again modulo nine. If you multiply, the residue of the true product must equal the product of the residues of the factors, again modulo nine. A mismatch is decisive: no correct total can disagree with its combined operand residues.
Agreement is not decisive: you can still be off by nine, eighteen, or any multiple of nine, or swap digits that preserve digit sum, and the modular check will still pass. That limitation is exactly why textbooks present casting out nines as a quick filter rather than a full proof. Residues are reported in the closed set zero through eight so signed integers and zero have a uniform representation; the mathematical content is the same as classical digit-sum casting.
What to enter and what you get back
Field claimed is the integer result you assert for those operands. Field operation is the enum sum or product so the engine knows whether to add or multiply residues. Example: operands one hundred twenty-three and four hundred fifty-six with claimed five hundred seventy-nine and operation sum produce residues six and six, combined residue three, claimed residue three, and passes true.
The same operands with claimed five hundred seventy-eight fail because five hundred seventy-eight is congruent to two modulo nine. A product example is seven times eight claimed as fifty-six: residues seven and eight multiply to two modulo nine, matching fifty-six. Fewer than two operands always errors before any modular work, matching the published contract that multi-operand checks need at least a pair.
What you can do with it
Classroom modular-arithmetic demos
Show students live passes and fails for sum and product claims while teaching digit sums, digital roots, and congruence modulo nine.
Homework and contest answer screening
Reject obviously wrong addition or multiplication answers that fail casting out nines before spending time on full re-grading.
Lightweight ledger and inventory sanity checks
Filter multi-operand totals and products with a deterministic mod-9 check in scripts that need a cheap consistency gate.
FAQ
How do I verify a sum with casting out nines?
Send operands as an array of at least two integers, claimed as the asserted total, and operation set to sum. The response compares the sum of residues mod 9 with the claimed residue and sets passes accordingly.
How do I verify a product?
Use the same operands and claimed fields with operation set to product. Residues are multiplied modulo 9 and compared with the claimed residue.
What happens if I supply fewer than two operands?
Casting out nines on a claimed multi-operand result requires at least two operands.
Does a passing check prove the answer is correct?
No. Agreement only shows consistency mod 9. Errors of a multiple of nine or digit swaps that preserve residue can still pass. A failing check proves the claim is wrong.
Why does casting out nines work?
Because 10 leaves a remainder of 1 when divided by 9, every whole number has the same remainder mod 9 as the sum of its digits. So the remainders of the parts must combine into the remainder of a correct result.
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/casting-out-nines \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"operands":[123,456],"claimed":579,"operation":"sum"}'const res = await fetch("https://api.kit.forhosting.com/numth/casting-out-nines", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"operands": [
123,
456
],
"claimed": 579,
"operation": "sum"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/casting-out-nines",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"operands": [
123,
456
],
"claimed": 579,
"operation": "sum"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/casting-out-nines", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"operands":[123,456],"claimed":579,"operation":"sum"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"operands":[123,456],"claimed":579,"operation":"sum"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/casting-out-nines", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"operands": [
123,
456
],
"claimed": 579,
"operation": "sum"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.casting_out_nines",
"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.
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
The engine is pure and deterministic, runs free in the browser for teaching demos, and costs $0.002 per successful API item when you need the same check from scripts, graders, or homework helpers.
What casting out nines means and why mod 9 works
This endpoint returns both residues and a boolean passes flag so learners can see the modular comparison explicitly instead of only hearing that the nines were cast out.
Input contract, response shape, and failure modes
Send a JSON object with three required pieces. Field operands is an array of at least two finite safe integers; fewer than two operands fails with invalid_input because casting out nines needs a multi-operand claim to verify. Aliases numbers, values, and terms are accepted for the operand list; result and total are accepted for the claim; op and mode are accepted for the operation. Non-integers, missing fields, empty arrays, single-element arrays, and values outside the safe integer range fail with invalid_input and are not billed. On success the response echoes operation, operands, and claimed, then lists operand_residues, combined_residue, claimed_residue, a passes boolean, a fixed check label casting_out_nines, and a short note that explains whether a match only shows consistency or a mismatch proves error.
Where a casting-out-nines API earns its keep
Classrooms that teach divisibility rules and modular arithmetic use casting out nines as the first practical checksum students can apply by hand; an automated oracle lets tutors show live failures when a student off-by-one answer disagrees mod nine. Contest coaches and homework platforms can screen candidate answers before full re-evaluation, catching many addition and multiplication mistakes cheaply. Pair it with a digital-root calculator when you only need the single-number residue, and with full arithmetic tools when you need the exact sum or product rather than a modular consistency check.
Technical questions
What does the casting out nines check cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful item; invalid input is not billed.