Modulo Operation/Examples/5 mod -3

From ProofWiki
Jump to navigation Jump to search

Theorem

$5 \bmod -3 = 5$

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 5 {-3} = -2 + \dfrac 1 3$

and so:

$\left\lfloor{\dfrac 5 {-3} }\right\rfloor = -2$


Thus:

\(\displaystyle 5 \bmod -3\) \(=\) \(\displaystyle 5 - \left({-3}\right) \times \left\lfloor{\dfrac 5 {-3} }\right\rfloor\)
\(\displaystyle \) \(=\) \(\displaystyle 5 - \left({-3}\right) \times \left({-2}\right)\)
\(\displaystyle \) \(=\) \(\displaystyle 5 - 3 \times 2\)
\(\displaystyle \) \(=\) \(\displaystyle -1\)

$\blacksquare$


Sources