0% found this document useful (0 votes)
27 views18 pages

Lecture 4 1

This document discusses modular arithmetic and divisibility. It defines concepts like congruences, the division algorithm, and laws of modular arithmetic. Proofs are provided for theorems regarding divisibility, congruences, and properties of modular arithmetic like closure, associativity, and distributivity.

Uploaded by

hallertjohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views18 pages

Lecture 4 1

This document discusses modular arithmetic and divisibility. It defines concepts like congruences, the division algorithm, and laws of modular arithmetic. Proofs are provided for theorems regarding divisibility, congruences, and properties of modular arithmetic like closure, associativity, and distributivity.

Uploaded by

hallertjohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Divisibility and Modular Arithmetic – Rosen

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

It is Thursday 23.02.2023, 10:20.


1. What time will it be in 263 minutes?
I 263 = 4 · 60 + 23, hence it will be 14:43.

2. What day of the week will it be in 347 days?


I 347 = 49 · 7 + 4, hence it will be Monday.

3. What will be the date in 67 days?


I ???

I 1 and 2 are easy, because time and weekdays follow strict


periodicity2 .
I Modular arithmetic is counting with periods.

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

I If a and b are integers with a 6= 0, we say that a divides b, written


a | b, if there is an integer c such that b = ac. Then a is called a
factor or divisor of b, and b a multiple of a.
I Examples:
I 3 divides 6: 6 = 3 · 2
I 6 divides 24: 24 = 6 · 4
I 3 divides 24: 24 = 6 · 4 = (3 · 2) · 4 = 3 · (2 · 4)
I 3 divides 30: 30 = 6 + 24 = (3 · 2) + (3 · 8) = 3 · (2 + 8)

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).

2. If a | b then there exists an integer k such that b = ak. Let c be an


arbitrary integer. Then bc = (ak)c = a(kc) and hence a | bc.

3. If a | b ∧ b | c then there exists integers k, l such that b = ak and


c = bl. Hence c = bl = (ak)l = a(kl) and a | c.

4. For all m, n we have from (ii) that a | b → a | mb and


a | c → a | (nc). Hence from (i) it follows that a | (mb + nc).

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

I −136 = 60 · (−3) + 44, hence

−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

If a and b are integers and m is a positive integer, then a is congruent


to b modulo m, written a ≡ b (mod m), if m divides a − b.
We say that a ≡ b (mod m) is a congruence and m is its modulus.

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

I In r = a mod d, modd refers to an operation that reduces the


integer a to an integer r , where 0 ≤ r < d.
I In a ≡ b (mod m), (mod m) is used together with ≡ to state that
a and b have the relation that m | a − b.

8
Theorem
For all integers a, b, c, m with m positive, we have

(i) a≡a (mod m)


(ii) a≡b (mod m) → b ≡ a (mod m)
(iii) a≡b (mod m) ∧ b ≡ c (mod m) → a ≡ c (mod m)

9
Proof.
1. a − a = 0 = 0 · m.

2. If a ≡ b (mod m), then a − b = km, for k ∈ Z.

Then b − a = −(a − b) = −km = (−k)m.


3. If a ≡ b (mod m) and b ≡ c (mod m), the a − b = km and b − c = lm,
k, l ∈ Z.
Then a − c = (a − b) + (b − c) = km + lm = (k + l)m.

10
Theorem
For all integers a, b, c, m with m positive, we have

(i) a≡b (mod m) ↔ a mod m = b mod m


(ii) a≡b (mod m) ↔ ∃k(a = b + km)
(iii) a ≡ b (mod m) ∧ c ≡ d (mod m) → a + c ≡ b + d (mod m)
(iv ) a ≡ b (mod m) ∧ c ≡ d (mod m) → ac ≡ bd (mod m)

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).

2. Follows immediately from the definition of congruence.

3. If a ≡ b (mod m) and c ≡ d (mod m) then there exist k, l such that


a − b = mk and c − d = ml.
I Hence (a + c) − (b + d) = m(k + l) or a + c ≡ b + d (mod m).

4. If a ≡ b (mod m) and c ≡ d (mod m) then there exist k, l such that


a − b = mk and c − d = ml.
I Hence ac = (b + mk)(d + ml) = bd + m(lb + kd + mkl).
I Hence ac ≡ bd (mod m).

12
Corollary
For all integers a, b, m with m positive,

a + b ≡ (a mod m) + (b mod m) (mod m)


ab ≡ (a mod m)(b mod m) (mod m)

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),

a + b ≡ (a mod m) + (b mod m) (mod m)


ab ≡ (a mod m)(b mod m) (mod m)

13
Modular arithmetic

Modular arithmetic or arithmetic modulo m operates on


Zm = {0, 1, . . . , m − 1}, the set of nonnegative integers less than m:

a +m b := (a + b) mod m
a ·m b := (ab) mod m

Directly from the corollary we get (why? Left as exercise!)

(a + b) mod m = ((a mod m) + (b mod m)) mod m


(a · b) mod m = ((a mod m) · (b mod m)) mod m

Modular arithmetic satisfies the properties of closure, associativity,


commutativity and distributivity, and has identity elements and additive
inverses.

14
Laws for modular arithmetic

For all the laws we have a, b, c ∈ Zm


I Closure: a +m b ∈ Zm and a ·m b ∈ Zm .
I This follows directly from the division algorithm.
I Associativity: (a +m b) +m c = a +m (b +m c) and
(a ·m b) ·m c = a ·m (b ·m c)
I For addition:

(a +m b) +m c = ((a + b) mod m + c) mod m


= ((a + b) mod m + c mod m) mod m
= (a + b + c) mod m = (a + (b + c) mod m) mod m
= a +m (b +m c)

I For mulitplication: Same proof, just replace + by · everywhere.


I Commutativity: a +m b = b +m a and a ·m b = b ·m a.
I a +m b = (a + b) mod m = (b + a) mod m = b +m a.
I a ·m b = (a · b) mod m = (b · a) mod m = (b ·m a).

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

I The second one: analogous proof.


I Identity elements: For 0 and 1 we have a +m 0 = 0 +m a = a and
a ·m 1 = 1 ·m a = a.
I a +m 0 = 0 +m a = (0 + a) mod m = a.
I a ·m 1 = 1 ·m a = (1 · a) mod m = a.
I Additive inverse: There is an a0 ∈ Zm such that
a +m a0 = a0 +m a = 0.
I For a0 = m − a we have
a +m a0 = a0 +m a = ((m − a) + a) mod m = 0 mod m = 0.

16
Multiplicative inverse?

A multiplicative inverse to a ∈ Zm is a number a0 such that


a ·m a0 = a0 ·m a = 1.
I Among integers, only ±1 have multiplicative inverses
I Among real numbers, all numbers except 0 have multiplicative
inverses
I Whether a ∈ Zm has an inverse depends on a and m.
I We will study this a few lectures from now.

17
Exercises

I Prove what is left as an exercise on slide 14.


I Make sure that you understand and can reproduce the proofs of this
lecture.

19

You might also like