Work out modular arithmetic instantly with clear inputs, formula shown and shareable results.
Modular arithmetic works with remainders. Addition, subtraction and multiplication all pass through the modulus cleanly, but division requires a modular inverse, which exists only when the divisor is coprime to the modulus.
Modular operations
(a ± b) mod m and (a × b) mod m can each be reduced at every step
47 ≡ 8 and 18 ≡ 5, so the sum is 0, the product is 40 ≡ 1 and the difference is 3.
The remainder is normalised by adding m before the final reduction, giving the least non-negative residue.