Modular Inverse
Find the least nonnegative inverse of a signed decimal integer modulo a decimal modulus of at least two, rejecting noncoprime pairs.
Description
A modular inverse reverses multiplication modulo m.
A modular inverse reverses multiplication modulo m. Such an inverse exists exactly when the supplied value and modulus are coprime.1
The tool returns inverse. The indexing and output conventions below determine how to read these values.
When to use Modular Inverse
Use this for the following task: Find the least nonnegative inverse of a signed decimal integer modulo a decimal modulus of at least two, rejecting noncoprime pairs. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Modular Inverse and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter value, modulus according to the field table, then run the tool.
- Read inverse. Preserve exact decimal strings and the stated indexing or coefficient order.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| value | Signed integer | string (integer/arbitrary); maximum text length 200; pattern ^-?(0|[1-9][0-9]*)$ | Required |
| modulus | Positive modulus | string (integer/arbitrary); maximum text length 200; pattern ^[1-9][0-9]*$ | Required |
Read signed value and positive modulus strings with BigInt, require modulus at least two, and use extended Euclid. Normalize the coefficient into the least nonnegative residue.
value×inverse ≡ 1 mod m; 0≤inverse<m The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| inverse | Least nonnegative modular inverse | string (integer/arbitrary) |
{
"input": {
"value": "17",
"modulus": "43"
},
"output": {
"inverse": "38"
}
} Limitations and assumptions
A noncoprime pair gives an error rather than zero. Each input string is capped at 200 characters; a decimal fraction or floating-point number is not a modular integer.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Linear Congruence Solver when you need its operation: Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields. Choose Extended Euclidean Coefficients for the complementary operation: Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.
Background reference: Linear Congruences.
References
-
Linear Congruences — Mount Royal University, Mathematics LibreTexts
Similar or alternative tools
- Linear Congruence Solver
Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields.
- Extended Euclidean Coefficients
Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.