Congruence
a ≡ b (mod m) ⇔ m | (a − b)
Two integers are congruent when their difference is divisible by the positive modulus.
Private by design: entered integers are validated and calculated on this device. They are not uploaded, stored, or added to the page URL.
a ≡ b (mod m) ⇔ m | (a − b)
Two integers are congruent when their difference is divisible by the positive modulus.
a·x ≡ 1 (mod m)
An inverse exists exactly when gcd(a, m) = 1. The extended Euclidean algorithm finds x.
r ≡ aᵉ (mod m)
Binary exponentiation repeatedly squares the base and reduces after every multiplication, avoiding construction of the full power.
For a positive modulus m, this calculator reports the canonical residue r satisfying 0 ≤ r < m. This convention makes the displayed answer consistent even when an input is negative.
38 ≡ 14 (mod 12) because both canonical residues are 2. Equivalently, 38 − 14 = 24 = 2·12.
The inverse of 17 modulo 43 is 38 because 17·38 = 646 = 15·43 + 1. Therefore 17·38 ≡ 1 (mod 43).
7¹²⁸ mod 13 = 3. Repeated squaring evaluates it with eight binary-exponentiation rounds instead of multiplying 7 by itself 127 times.
Every input must be a base-10 integer written without commas, decimal points, scientific notation, or arithmetic expressions. A leading plus or minus sign is accepted where signed input is meaningful. The modulus must be a positive integer of at least 2, and modular-power exponents must be nonnegative. For exponent 0, the calculator uses the empty-product convention a⁰ = 1, including when the entered base is 0.
Congruence is tested both by comparing canonical residues and by checking divisibility of a − b. Inverses are calculated with the extended Euclidean algorithm after reducing a modulo m. Powers use exponentiation by squaring, so work grows with the number of binary digits in the exponent rather than with the exponent itself.
Each input is limited to 200 digits, excluding an optional sign. Calculations use JavaScript BigInt, so results are exact integers rather than floating-point approximations. The on-screen power trace is limited to the first 24 rounds; the final result still uses every round.
Calculation note: definitions, sign handling, existence conditions, and the representative examples were checked against the stated identities. Last reviewed: .
It means that m divides a − b. Equivalently, a and b have the same canonical remainder from 0 through m − 1.
Reduce the number modulo m and, if the programming-language remainder is negative, add m. The calculator always reports the canonical residue in the range 0 through m − 1.
An integer a has a multiplicative inverse modulo m exactly when gcd(a, m) = 1. If the GCD is larger than 1, no integer can multiply a to produce residue 1.
All integers congruent to the reported inverse work. The calculator reports the unique canonical representative between 0 and m − 1.
The tool uses binary exponentiation, also called repeated squaring. It reduces modulo m after each multiplication, so it never needs to store the generally enormous value of aᵉ.
This calculator accepts nonnegative exponents. A negative exponent would first require a modular inverse of the base, and that inverse does not always exist.
This tool uses the standard computational convention of a positive modulus with at least two residue classes. It therefore rejects zero, negative moduli, and modulus 1.
No. Validation, calculation, and copy preparation run locally in your browser. The tool does not transmit or save entered values.