Modular division calculator
Divide in modular arithmetic: 8 divided by 3 modulo 11 is 10, because the inverse of 3 is 4 and 3 times 10 leaves the remainder 8. You also get the inverse, the gcd and a check value. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- A
- 8
- B
- 3
- N
- 11
- A mod
- 8
- B mod
- 3
- Inverse
- 4
- Quotient
- 10
Modular division asks for a residue q such that b times q is congruent to a modulo n. In ordinary arithmetic you simply divide; in modular arithmetic division is multiplication by the modular inverse of the divisor. That inverse exists only when b and n are coprime. Cryptography labs, contest programming, finite-field homework, and linear-congruence drills all need this operation, yet many languages expose only GCD or a bare modular inverse and leave the multiply step to you. This calculator takes integers a, b, and modulus n, inverts b modulo n with the extended Euclidean algorithm when possible, multiplies by a, and returns the unique non-negative quotient in zero through n minus one, together with the inverse, the gcd, and a check product so you can verify the result without re-deriving the steps.
What modular division means and when it is defined
In the integers every non-zero number has a reciprocal in the rationals, so division is always defined away from zero. Modulo n the picture is stricter: residues form a ring, and only units—elements that have a multiplicative inverse—can appear as legal divisors. We say q is a modular quotient of a divided by b modulo n when b times q leaves the same remainder as a when both products are reduced modulo n.
Equivalently, q is congruent to a times b inverse modulo n. The inverse of b exists if and only if gcd of b and n equals one; otherwise every multiple of b shares a common factor with n and cannot hit every residue class, so no single q works for arbitrary a.
Engineers and students meet this barrier when they try to divide in a composite modulus that is not a prime field, when they cancel a coefficient in a linear congruence, or when they undo a modular multiplication in a hash or cipher step. Note that a itself need not be coprime to n; only the divisor b must be a unit. That asymmetry is easy to forget when you only remember the modular-inverse special case a equals one.
Practical use, limits, pricing, and delivery
Use the browser tool when you want a quick modular quotient while reading a number-theory note, checking homework of the form b x congruent to a mod n, or debugging a modular pipeline that already multiplies by inverses by hand. Accepted inputs are integers a and b with absolute value at most one trillion and moduli n from two through one trillion. Results are deterministic: the same triple always yields the same quotient, inverse, and check fields.
If you only need b inverse without multiplying by a, prefer the dedicated modular inverse capability; this page targets the full division intent that searchers phrase as modular division or a divided by b mod n.
What you can do with it
Crypto and finite-field teaching labs
Instructors and students can divide field elements modulo a prime, or inspect the gcd when a sample composite modulus makes the divisor non-invertible.
Homework checkers and linear congruences
Automated graders can verify solutions of b x ≡ a (mod n) by comparing the returned quotient, and reject cases where no unique residue class exists.
FAQ
What happens if b is not invertible modulo n?
The message includes gcd(b, n) so you know why modular division is undefined. Failed validation is not charged.
How is the quotient computed?
The extended Euclidean algorithm finds b⁻¹ mod n when gcd(b, n) = 1; the calculator then multiplies that inverse by a modulo n with exact integer arithmetic.
Is the modular division calculator free?
The browser tool runs free on your device.
What ranges of a, b, and n are accepted?
n must be an integer from 2 through 1,000,000,000,000. a and b must be integers whose absolute values are at most that same bound. Values outside those limits are rejected.
What is 8 divided by 3 modulo 11?
The answer is 10. The inverse of 3 modulo 11 is 4, and multiplying 8 by it gives the quotient 10. As a check, 3 times 10 leaves the remainder 8 when divided by 11.
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/modular-division \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":8,"b":3,"n":11}'const res = await fetch("https://api.kit.forhosting.com/numth/modular-division", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 8,
"b": 3,
"n": 11
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/modular-division",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 8,
"b": 3,
"n": 11
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/modular-division", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":8,"b":3,"n":11}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":8,"b":3,"n":11}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/modular-division", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": 8,
"b": 3,
"n": 11
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.modular_division",
"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
What modular division means and when it is defined
Returning an explicit invalid_input error when b is not invertible is more useful than a silent wrong residue: the client learns that division is undefined for that pair and can branch on the reported gcd instead of trusting a library that returned a half-baked value.
How this calculator inverts b and multiplies by a
Call the capability with integer fields a, b, and n, where n is at least two. The implementation first reduces a and b into non-negative residues a_mod and b_mod in the range zero through n minus one, then runs the extended Euclidean algorithm on b_mod and n. Each step records the integer quotient and updates Bézout coefficients so that at termination the coefficient of b_mod multiplies b_mod plus a coefficient of n equals the gcd. If that gcd is not one, the request fails with invalid_input and a message that names b, n, and the gcd; nothing is charged. If the gcd is one, the coefficient of b_mod is reduced into zero through n minus one and stored as inverse. The modular product of a_mod and inverse is then taken with exact BigInt arithmetic so large residues stay correct up to the published bound, and the product is returned as quotient. The response also echoes a, b, n, a_mod, b_mod, gcd, and check equal to b_mod times quotient modulo n, which must equal a_mod whenever the call succeeds. Absolute values of a and b, and the modulus n, are bounded by one trillion so every intermediate stays within a safe integer regime for the Worker isolate.
Practical use, limits, pricing, and delivery
Use the API when a script, grader, or educational platform needs many divisions without embedding an extended-GCD routine and a careful multiply-mod step. Each successful request is one billable item at $0.002; validation failures and non-invertible divisors do not consume balance. Wire the endpoint into contest helpers, finite-field demos, RSA teaching sandboxes that need more than bare inverses, or any integer pipeline that prefers exact arithmetic over floating-point heuristics. Because the unit is a single item and the engine is pure parse, latency stays low and the free web channel mirrors the paid API without a second code path that could drift.
Integration use cases
Contest programming and modular arithmetic
Competitive programmers can compute a/b mod n under prime or composite moduli and catch non-invertible divisors via invalid_input instead of shipping ad-hoc extended-GCD snippets.
Technical questions
How do I compute modular division a ÷ b mod n?
Send JSON with integer fields a, b, and n (n ≥ 2) to numth.modular_division. On success the response returns quotient in 0..n−1, plus inverse of b, a_mod, b_mod, gcd, and check equal to a_mod.