Skip to content
ENExplore Calculators

Modular Arithmetic Calculator

Work out modular arithmetic instantly with clear inputs, formula shown and shareable results.

About Modular Arithmetic Calculator

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.

Formula

Modular operations

(a ± b) mod m and (a × b) mod m can each be reduced at every step

Worked example

With the default values below, Modular Arithmetic Calculator returns a × b mod m of 1. Change any input above and every figure here is recalculated in your browser.

Inputs used

First operand a
47
Second operand b
18
Modulus mminimum 2
13

Results

a × b mod m
1
a + b mod m
0
a − b mod m
3
Inverse of b mod m (0 if none)
8

Step by step

  1. 1Values used
  2. 2Modular operations
  3. 3a × b mod m= 1
  4. 4a + b mod m= 0
  5. 5a − b mod m= 3
  6. 6Inverse of b mod m (0 if none)= 8

Assumptions and limits

  • The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

For a = 47, b = 18, m = 13?

47 ≡ 8 and 18 ≡ 5, so the sum is 0, the product is 40 ≡ 1 and the difference is 3.

Why is the result never negative?

The remainder is normalised by adding m before the final reduction, giving the least non-negative residue.

Modular Arithmetic Calculator | Calcrivo