Modulo Operation/Examples/5 mod -3

From ProofWiki
Jump to navigation Jump to search

Theorem

$5 \bmod -3 = -1$

where $\bmod$ denotes the modulo operation.


Proof

By definition of modulo operation:

$x \bmod y := x - y \floor {\dfrac x y}$

for $y \ne 0$.


We have:

$\dfrac 5 {-3} = -2 + \dfrac 1 3$

and so:

$\floor {\dfrac 5 {-3} } = -2$


Thus:

\(\ds 5 \bmod -3\) \(=\) \(\ds 5 - \paren {-3} \times \floor {\dfrac 5 {-3} }\)
\(\ds \) \(=\) \(\ds 5 - \paren {-3} \times \paren {-2}\)
\(\ds \) \(=\) \(\ds 5 - 3 \times 2\)
\(\ds \) \(=\) \(\ds -1\)

$\blacksquare$


Sources