Modulo Calculator

Enter a number and a modulus to find the remainder, or add an exponent for a power mod n.

Any whole number, positive or negative.

A whole number other than 0.

Try

Result

You entered17 mod 517 \bmod 5

17 mod 5=2\displaystyle 17 \bmod 5 = 2

Quotient

3\displaystyle 3

Truncated remainder

2\displaystyle 2

Congruence

17≡2(mod5)\displaystyle 17 \equiv 2 \pmod{5}
Show the work
  1. Division algorithm

    Dividing aa by nn and rounding the quotient down to a whole number qq leaves a remainder rr that is never negative. Here a=17a = 17 and n=5n = 5.

    Using a=n×q+r,0≤r<na = n \times q + r, \quad 0 \le r < n

    q=⌊175⌋=3\begin{aligned} q &= \left\lfloor \frac{17}{5} \right\rfloor \\ &= 3 \end{aligned}
  2. Remainder from the quotient

    The remainder is what is left of aa after taking away qq whole copies of nn. Here q=3q = 3, so rr lands between 00 and 44.

    r=a−n×q=17−5×3=17−15=2\begin{aligned} r &= a - n \times q \\ &= 17 - 5 \times 3 \\ &= 17 - 15 \\ &= 2 \end{aligned}
  3. Result

    So 17 mod 5=217 \bmod 5 = 2.

Worked examples