Lecture 4 1
Lecture 4 1
Section 4.1
Anna-Simone Frank1
MNF130
Spring 2024
1
Slides created by Tom Michoel and modified by Erik Maartensson and
Anna-Simone Frank
Examples
2 takingthe length of different months plus leap years into consideration, dates are
periodic too, but the period is 400 years and dates are still much trickier to deal with.2
Integer division
3
Theorem
For all integers a, b, c, m, n with a 6= 0, we have3
(i) a | b ∧ a | c → a | (b + c)
(ii) a | b → ∀c(a | bc)
(iii) a|b ∧ b|c → a|c
(iv ) a | b ∧ a | c → a | (mb + nc)
3 notice that | has higher precedence than ∧. Also, for (iii) we have b 6= 0. 4
Proof.
1. If a | b ∧ a | c then there exists integers k, l such that b = ak and
c = al. Hence b + c = ak + al = a(k + l), or a | (b + c).
5
The division algorithm4
If a is an integer and d a positive integer, then there exist unique integers
q, the quotient, and r , the remainder, with 0 ≤ r < d, such that
a = dq + r . We write:
q = a div d = ba/dc
r = a mod d = a − dba/dc
Example
I 136 = 2 · 60 + 16, hence
136 div 60 = 2
136 mod 60 = 16
−136 div 60 = −3
−136 mod 60 = 44
4 It’s
actually a theorem rather than an algorithm, but traditionally it’s called an
algorithm. 6
Congruences
Example
I 9 ≡ 3 (mod 6): 9 − 3 = 6 = 6 · 1.
I 135 ≡ 15 (mod 60): 135 − 15 = 120 = 60 · 2
7
The two meanings of mod
8
Theorem
For all integers a, b, c, m with m positive, we have
9
Proof.
1. a − a = 0 = 0 · m.
10
Theorem
For all integers a, b, c, m with m positive, we have
11
Proof.
1. If a ≡ b (mod m), then m | a − b, or ∃c such that a − b = mc.
I Let b mod m = r and b div m = q, that is, b = mq + r with
0 ≤ r < m.
I Then a = b + mc = mq + r + mc = m(q + c) + r and hence
a mod m = r = b mod m.
I Conversely, let a mod m = b mod m = r .
I Then a − b = mq + r − (mp + r ) = m(q − p) where q = a div m and
p = b div m.
I Hence m | (a − b) or a ≡ b (mod m).
12
Corollary
For all integers a, b, m with m positive,
Proof.
I Let a mod m = r .
I Then by definition, 0 ≤ r < m and r mod m = r .
I Hence a ≡ (a mod m) (mod m).
I Likewise b ≡ (b mod m) (mod m).
I Hence by the previous theorem (iii) and (iv),
13
Modular arithmetic
a +m b := (a + b) mod m
a ·m b := (ab) mod m
14
Laws for modular arithmetic
15
Laws for modular arithmetic 2
I Distributivity: a ·m (b +m c) = a ·m b +m a ·m c and
(a +m b) ·m c = a ·m c +m b ·m c
I The first one:
a ·m (b +m c) = (a · (b + c) mod m) mod m
= ((ab) mod m + (ac) mod m) mod m
= a ·m b + m a ·m c
16
Multiplicative inverse?
17
Exercises
19