Modulo Operation/Examples/18 mod -3

From ProofWiki
Jump to navigation Jump to search

Theorem

$18 \bmod -3 = 0$

where $\bmod$ denotes the modulo operation.


Proof

By definition of modulo operation:

$x \bmod y := x - y \left \lfloor {\dfrac x y}\right \rfloor$

for $y \ne 0$.


We have:

$\dfrac {18} {-3} = -6 + \dfrac 0 3$

and so:

$\left\lfloor{\dfrac {18} {-3} }\right\rfloor = -6$


Thus:

\(\displaystyle 18 \bmod -3\) \(=\) \(\displaystyle 18 - \left({-3}\right) \times \left\lfloor{\dfrac {18} {-3} }\right\rfloor\)
\(\displaystyle \) \(=\) \(\displaystyle 18 - \left({-3}\right) \times \left({-6}\right)\)
\(\displaystyle \) \(=\) \(\displaystyle 18 - 3 \times 6\)
\(\displaystyle \) \(=\) \(\displaystyle 0\)

$\blacksquare$


Sources