Modulo Operation/Examples/-100 mod 7
Jump to navigation
Jump to search
Theorem
- $-100 \bmod 7 = 5$
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 {-100} 7 = -15 + \dfrac 5 7$
and so:
- $\floor {\dfrac {-100} 7} = -15$
Thus:
\(\ds -100 \bmod 7\) | \(=\) | \(\ds -100 - 7 \times \floor {\dfrac {-100} 7}\) | ||||||||||||
\(\ds \) | \(=\) | \(\ds -100 + 7 \times 15\) | ||||||||||||
\(\ds \) | \(=\) | \(\ds 5\) |
$\blacksquare$
Sources
- 1997: Donald E. Knuth: The Art of Computer Programming: Volume 1: Fundamental Algorithms (3rd ed.) ... (previous) ... (next): $\S 1.2.4$: Integer Functions and Elementary Number Theory: Exercise $8$