Compute a mod m and modular addition, subtraction, multiplication and powers, with the congruence shown.
Result
How to use this tool
Enter the first number, the second number (or exponent for powers) and the modulus m.
Pick a plain remainder, or addition, subtraction, multiplication or a power reduced modulo b.
Read the reduced result, the unreduced value where shown, and the congruence.
For a mod b, verify that a = quotient × b + remainder.
Formula & worked example
17 mod 5 = 2, because 17 = 3 × 5 + 2.
Limitations — read this before you rely on it
Powers use whole-number exponents of 0 or more up to 10000. Very large inputs can lose integer precision in floating-point arithmetic.
Frequently asked questions
It is the remainder when a is divided by m. This calculator uses the Euclidean remainder, which is always between 0 and |m| − 1, even for negative a.
Add first, then take the remainder modulo m. The same idea applies to subtraction and multiplication.
By repeated squaring, which keeps every intermediate value below the modulus instead of computing the huge power first.
It means a and r leave the same remainder on division by b, so they belong to the same residue class.
Division by zero is undefined, so a modulus of zero has no remainder.
