Professional Documents
Culture Documents
MTH314
20 n io (c 7
Discrete Mathematics
on o 1
ity
rs e -W
rs
for Engineers
g
4
r
R K 31
TH
G
U
05 Number Theory
ye .
M
Department of Mathematics
Sharing and/or posting online this manuscript, or parts of it, are strictly1forbidden.
(c) K. Georgiou, Ryerson University, 2019
19 ive u )
20 n io (c 7
on o 1
ity
rs e -W
rs
g
4
r
Divisibility
R K 31
TH
G
U
ye .
M
Sharing and/or posting online this manuscript, or parts of it, are strictly2forbidden.
(c) K. Georgiou, Ryerson University, 2019
Divisibility
Definition:
19 ive u )
20 n io (c
We say that (a non zero) integer 𝑎𝑎 divides an integer 𝑏𝑏 , if there exists integer q, with
b = q⋅a
7
on o 1
ity
rs e -W
Notation: a | b will mean from now on that a divides b. (not to be confused with a / b )
rs
g
4
a | b will mean from now on that a does not divide b.
r
R K 31
Observation: 𝑎𝑎|𝑏𝑏 ≡ ∃𝑞𝑞 ∈ ℤ, 𝑏𝑏 = 𝑞𝑞 ⋅ 𝑎𝑎
TH
G
U
ye .
M
Example: 5 | 12 ? No, because for all integers q we have 12 ≠ q ⋅ 5 (Is this complete?)
19 ive u )
20 n io (c
Lemma: For all integers n≥0 we have
7
0 = q⋅n
on o 1
Proof: Set q=0, and note that
ity
n|0
rs e -W
rs
1| n Proof: Set q=n, and note that n = q ⋅1
g
4
r
R K 31
Lemma: For all integers a,b we have (a | b ) ∧ (b | c ) → (a | c )
TH
G
U
Example:
(4 | 12) ∧ (12 | 132) → (4 | 132)
a | b means ∃q1 ∈ Z (b = q1 ⋅ a )
ye .
M
Proof:
b | c means ∃q2 ∈ Z (c = q2 ⋅ b )
19 ive u )
20 n io (c 7
on o 1
ity
Lemma: For all integers a,b we have [(a | b ) ∧ (b | a )] → [(a = b ) ∨ (a = −b )]
rs e -W
rs
g
4
r
R K 31
TH
G
U
Lemma: For all integers 𝑎𝑎, 𝑏𝑏 with 𝑎𝑎, 𝑏𝑏 > 0 we have (a | b ) → (a ≤ b )
ye .
M
(
Example: Is it possible that (a > 0 ) ∧ (a | b ) ∧ a > b ? )
Sure, as long as b=0.
© K. Georgiou Sharing and/or posting online this manuscript, or parts of it, are strictly5forbidden.
(c) K. Georgiou, Ryerson University, 2019
𝑷𝑷 𝟎𝟎 ∧ ∀𝒏𝒏 ≥ 𝟎𝟎, 𝑷𝑷 𝒏𝒏 → 𝑷𝑷 𝒏𝒏 + 𝟏𝟏 → ∀𝒏𝒏 ≥ 𝟎𝟎, 𝑷𝑷 𝒏𝒏
19 ive u )
20 n io (c
Theorem
7
on o 1
ity
∀𝑛𝑛 ∈ ℤ≥0 , 3|(22𝑛𝑛 − 1)
rs e -W
rs
g
4
Proof:
r
R K 31
Define predicate 𝑃𝑃 𝑛𝑛 : 3|(22𝑛𝑛 − 1)
TH
G
U
Will show by induction on 𝑛𝑛 that ∀𝑛𝑛 ≥ 0, 𝑃𝑃 𝑛𝑛 .
ye .
M
Basic Step: Need to verify that 3|(20 −1). But 3|0, because
0 = 0 ⋅ 3, so the basic step is complete.
Inductive Step: Need to prove that
∀𝒏𝒏 ≥ 𝟎𝟎, 𝑷𝑷 𝒏𝒏 → 𝑷𝑷 𝒏𝒏 + 𝟏𝟏
Sharing and/or posting online this manuscript, or parts of it, are strictly6forbidden.
(c) K. Georgiou, Ryerson University, 2019
Goal: ∀𝒏𝒏 ≥ 𝟎𝟎, 𝑷𝑷 𝒏𝒏 → 𝑷𝑷 𝒏𝒏 + 𝟏𝟏 𝑃𝑃 𝑛𝑛 : 3|(22𝑛𝑛 − 1)
(proof cont’d):
19 ive u )
Let 𝑚𝑚 be an arbitrary nonnegative integer.
20 n io (c
Assume that 𝑃𝑃(𝑚𝑚) is true, that is 3|(22𝑚𝑚 − 1).
7
This means that there exists integer 𝑘𝑘, with 22𝑚𝑚 − 1 = 3𝑘𝑘 (inductive
on o 1
ity
hypothesis)
rs e -W
rs
Need to show that 3|(22(𝑚𝑚+1) − 1)
g
4
r
R K 31
We have 22(𝑚𝑚+1) − 1 = 22𝑚𝑚+2 − 1
TH
G
U
= 2 2𝑚𝑚 22 − 1 (simple algebra)
= (3𝑘𝑘 + 1)22 − 1
ye .
M
(inductive hypothesis)
19 ive u )
20 n io (c
Example: Prove that
7
on o 1
ity
the sum of any two even integers is also even.
rs e -W
∀𝑛𝑛, 𝑘𝑘 ∈ ℤ, (2 𝑛𝑛 ∧ 2 𝑘𝑘) → 2|(𝑛𝑛 + 𝑘𝑘)
rs
g
4
Wrong Solution (arguing with examples):
r
R K 31
This is true because if m = 14 and n = 6, which are both
even, then m + n = 20, which is also even.
TH
G
U
ye .
M
19 ive u )
Example: Prove that
20 n io (c
the sum of any two even integers is also even.
7
on o 1
ity
∀𝑛𝑛, 𝑘𝑘 ∈ ℤ, (2 𝑛𝑛 ∧ 2 𝑘𝑘) → 2|(𝑛𝑛 + 𝑘𝑘)
rs e -W
Wrong Solution: (jumping to conclusion/undefined
rs
notation)
g
4
r
R K 31
Consider two even integers 𝑛𝑛, 𝑘𝑘.
We have, 𝑛𝑛 + 𝑘𝑘 = 2𝑟𝑟 + 2𝑠𝑠 which is also divisible by 2.
TH
G
U
ye .
M
19 ive u )
Example:
20 n io (c
Prove that the product of two odd integers is odd.
7
on o 1
ity
rs e -W
Wrong Solution: (another circular reasoning)
rs
g
Suppose 𝑚𝑚 and 𝑛𝑛 are any odd integers. We must show that
4
r
R K 31
𝑚𝑚𝑚𝑚 is odd.
This means that there exists an integer 𝑠𝑠 such that
TH
G
U
𝑚𝑚𝑚𝑚 = 2𝑠𝑠 + 1
ye .
M
19 ive u )
20 n io (c 7
on o 1
ity
Examples (words misuse):
rs e -W
rs
• If 𝑚𝑚 is an odd integer, then 𝑚𝑚 = 2𝑎𝑎 + 1 for any
g
4
r
integer 𝑎𝑎.
R K 31
TH
positive integers.
11forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Prime Numbers
(different from course notes)
19 ive u )
20 n io (c
Definition: An integer n≥2 is called prime if the only positive divisors of n
7
are the integers 1 and n (exactly two distinct divisors)
on o 1
ity
An integer n≥2 is called composite if it has more than two distinct divisors.
rs e -W
rs
Observations: 1 is neither prime or composite.
g
4
Every integer 𝑛𝑛 ≥ 2 is either prime or composite, exclusively.
r
R K 31
Note: 𝑝𝑝 ≥ 2 is prime ≡ ∀𝑘𝑘 ∈ ℤ, 𝑘𝑘|𝑝𝑝 → (𝑘𝑘 = 1 ∨ 𝑘𝑘 = 𝑝𝑝)
TH
G
U
𝑝𝑝 ≥ 2 is composite ≡ ∃𝑘𝑘 ∈ ℤ, 𝑘𝑘|𝑝𝑝 ∧ 𝑘𝑘 ≠ 1 ∧ 𝑘𝑘 ≠ 𝑝𝑝)
ye .
M
19 ive u )
Primality testing: Given an integer n, is it prime?
20 n io (c 7
Question: What is the size of the input of the above problem?
on o 1
ity
rs e -W
Size when n=4314? 4
rs
g
4
Size when n=3847568736225097324624314? 25
r
R K 31
Theorem: Number of digits in order to represent n is Θ(log n ) .
TH
G
U
Question: Is there a way to solve primality in polynomially many steps (in log n )?
ye .
M
19 ive u )
Theorem: Every integer more than 1 has a prime factor.
20 n io (c
∀𝑎𝑎 ∈ ℤ, 𝑎𝑎 ≥ 2 → ∃𝑝𝑝 ∈ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃, 𝑝𝑝 𝑎𝑎
7
on o 1
ity
Proof: Every integer is either prime or composite. So it is enough to prove that
rs e -W
(i) ∀𝑎𝑎 ∈ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃, 𝑎𝑎 ≥ 2 → ∃𝑝𝑝 ∈ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃, 𝑝𝑝 𝑎𝑎
rs
(ii) ∀𝑎𝑎 ∈ 𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶, 𝑎𝑎 ≥ 2 → ∃𝑝𝑝 ∈ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃, 𝑝𝑝 𝑎𝑎
g
4
r
R K 31
(i) is true because ….
TH
G
U
For the sake of contradiction, assume (ii) is false, i.e.
ye .
M
19 ive u )
20 n io (c
Theorem (Fundamental Theorem of Arithmetic):
7
Every integer > 1 has a unique representation as a product of prime powers.
on o 1
ity
rs e -W
Example: 9421868371896 = 2 ⋅ 2 ⋅ 2 ⋅ 3 ⋅ 3 ⋅ 3 ⋅ 3 ⋅ 3 ⋅ 3 ⋅17 ⋅17 ⋅17 ⋅17 ⋅ 23 ⋅ 29 ⋅ 29
rs
g
4
= 23 ⋅ 36 ⋅17 4 ⋅ 23 ⋅ 29 2 Prime power decomposition
r
R K 31
Theorem (restated):
TH
G
U
For every integer 𝑛𝑛 > 1, there exists integer 𝑘𝑘, and 𝑘𝑘 distinct primes
ye .
M
𝑝𝑝1 < ⋯ < 𝑝𝑝𝑘𝑘 , along with positive integers 𝑒𝑒1 , … , 𝑒𝑒𝑘𝑘 such that
𝑒𝑒 𝑒𝑒 𝑒𝑒
𝑛𝑛 = 𝑝𝑝11 ⋅ 𝑝𝑝22 ⋅ … 𝑝𝑝𝑘𝑘𝑘𝑘 .
This representation is unique, meaning that if for some integer 𝑙𝑙, and 𝑙𝑙 primes
𝑞𝑞1 < ⋯ < 𝑞𝑞𝑘𝑘 , along with positive integers 𝑡𝑡1 , … , 𝑡𝑡𝑙𝑙 we have
𝑡𝑡 𝑡𝑡 𝑡𝑡
𝑛𝑛 = 𝑞𝑞11 ⋅ 𝑞𝑞22 ⋅ … 𝑞𝑞𝑙𝑙 𝑙𝑙
then 𝑘𝑘 = 𝑙𝑙, 𝑝𝑝𝑖𝑖 = 𝑞𝑞𝑖𝑖 and 𝑒𝑒𝑖𝑖 = 𝑡𝑡_𝑖𝑖, 𝑖𝑖 = 1, … , 𝑘𝑘. 15forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Proof of Unique Factorization Thm
Theorem (restated):
19 ive u )
20 n io (c
∀𝑛𝑛 > 1, there exists integer 𝑘𝑘, and 𝑘𝑘 distinct primes
𝑝𝑝1 < ⋯ < 𝑝𝑝𝑘𝑘 , along with positive integers 𝑒𝑒1 , … , 𝑒𝑒𝑘𝑘 such that
7
on o 1
ity
𝑒𝑒 𝑒𝑒 𝑒𝑒
𝑛𝑛 = 𝑝𝑝11 ⋅ 𝑝𝑝22 ⋅ … 𝑝𝑝𝑘𝑘𝑘𝑘 .
rs e -W
rs
g
4
Proof:
r
R K 31
For the sake of contradiction, suppose there is 𝑛𝑛 > 1 that does not
TH
have this property.
G
U
We may assume that 𝑛𝑛 is the smallest such integer.
ye .
M
ity
rs e -W
rs
g
4
r
Greatest Common Divisor
R K 31
TH
G
U
ye .
M
17forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Greatest Common Divisors
19 ive u )
20 n io (c
Definition
7
on o 1
ity
Let 𝑎𝑎, 𝑏𝑏 ∈ ℤ not both 0. The greatest common divisor
rs e -W
rs
of 𝑎𝑎, 𝑏𝑏, denoted by gcd(𝑎𝑎, 𝑏𝑏), is the largest integer
g
4
r
that divides both 𝑎𝑎, 𝑏𝑏.
R K 31
TH
G
U
Observation: gcd ⋅,⋅ is well defined.
ye .
M
18forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Finding GCDs
Find gcd 12,24 .
19 ive u )
20 n io (c
Solution:
7
Divisors of 12: {±1, ±2, ±3, ±4, ±6, ±12}
on o 1
ity
Divisors of 24: {±1, ±2, ±3, ±4, ±6, ±12, ±24}.
rs e -W
rs
Hence gcd 12,24 = 12.
g
4
r
R K 31
Find gcd 16,20 .
TH
G
U
Solution:
ye .
M
19 ive u )
20 n io (c
Definition
7
on o 1
ity
Let 𝑎𝑎, 𝑏𝑏 be integers. For each 𝑘𝑘, 𝑙𝑙 integers,
rs e -W
rs
𝑘𝑘𝑘𝑘 + 𝑙𝑙𝑙𝑙
g
4
is called an integer combination of 𝑎𝑎, 𝑏𝑏.
r
R K 31
TH
G
U
Examples
ye .
M
20forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Property of Integer Combinations
19 ive u )
20 n io (c
Theorem For every integers 𝑑𝑑, 𝑎𝑎, 𝑏𝑏,
7
on o 1
ity
𝑑𝑑 𝑎𝑎 ∧ 𝑑𝑑 𝑏𝑏 → (𝑑𝑑 divides any integer combination of 𝑎𝑎, 𝑏𝑏)
rs e -W
(Corollary: 𝑑𝑑 𝑎𝑎 ∧ 𝑑𝑑 𝑏𝑏 → 𝑑𝑑|(𝑎𝑎 ± 𝑏𝑏) )
rs
g
4
r
Proof:
R K 31
Let 𝑑𝑑, 𝑎𝑎, 𝑏𝑏 be arbitrary integers for which 𝑑𝑑|𝑎𝑎 ∧ 𝑑𝑑|𝑏𝑏.
TH
G
U
But then ∃𝑟𝑟1 ∈ ℤ: 𝑎𝑎 = 𝑟𝑟1 𝑑𝑑
ye .
M
∃𝑟𝑟2 ∈ ℤ: 𝑏𝑏 = 𝑟𝑟2 𝑑𝑑
Let 𝑘𝑘𝑘𝑘 + 𝑙𝑙𝑙𝑙 be an arbitrary integer combination of 𝑎𝑎, 𝑏𝑏.
But then 𝑘𝑘𝑘𝑘 = 𝑘𝑘𝑟𝑟1 𝑑𝑑
𝑙𝑙𝑙𝑙 = 𝑙𝑙𝑟𝑟2 𝑑𝑑
Hence 𝑘𝑘𝑘𝑘 + 𝑙𝑙𝑙𝑙 = 𝑘𝑘𝑟𝑟1 𝑑𝑑 + 𝑙𝑙𝑟𝑟2 𝑑𝑑 = 𝑘𝑘𝑟𝑟1 + 𝑙𝑙𝑟𝑟2 𝑑𝑑.
Hence, 𝑑𝑑|(𝑘𝑘𝑘𝑘 + 𝑙𝑙𝑙𝑙) as wanted. ∎
21forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Correctness of Division (Proof) (1)
Theorem: Let a,b integers with b>0. Then there exist unique integers q,r :
19 ive u )
20 n io (c
divisor
Example: 𝑎𝑎 = 54, when divided by
a = b ⋅ q + r ,where 0≤r<b.
7
𝑏𝑏 = 4, has quotient 𝑞𝑞 = 13 and
on o 1
ity
dividend remainder remainder 𝑟𝑟 = 2, i. e.
quotient
rs e -W
54 = 4 ⋅ 13 + 2
rs
Proof: (for a≥0 – The case a<0 is similar) Consider the sequence f n = a − n ⋅ b
g
4
r
R K 31
f0 f1 f2 f3 f k −1 fk
TH
G
U
a , a − b , a − 2b , a − 3b , … , a − (k − 1) ⋅ b , a − k ⋅ b ,
ye .
M
Set r = a − (k − 1) ⋅ b b ⋅ q + r = b ⋅ (k − 1) + a − b ⋅ (k − 1) = a
and observe
q = k −1 r≥0 (why?)
r = a − (k − 1) ⋅ b = a − k ⋅ b + b < b
“proposed quotient”
22forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Correctness of Division (Proof) (2)
Theorem: Let a,b integers with b>0. Then there exist unique integers q,r :
19 ive u )
20 n io (c
divisor
a = b ⋅ q + r ,where 0≤r<b.
7
on o 1
ity
dividend remainder
rs e -W
quotient
rs
Proof (cont’d): (uniqueness)
g
4
r
We have shown that
R K 31a = b ⋅ q + r ,where 0 ≤ r < .b
Hence, b ⋅ q + r = b ⋅ q '+ r '
TH
G
U
Now, suppose that a = b ⋅ q '+ r ' ,where 0 ≤ r ' < b. that is b ⋅ (q '− q ) = r − r '
ye .
M
0≤r
⇒ −b < r − r ' this says b divides r-r’
r' < b
⇒ −b < r − r ' < b
this says b>|r-r’|
0 ≤ r'
⇒ r − r' < b ⇒ r − r' = 0
r <b
⇒ q − q' = 0
23forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Does this Smell Like a Function?
Theorem: Let a,b integers with b>0. Then there exist unique integers q,r :
19 ive u )
20 n io (c
divisor
a = b ⋅ q + r ,where 0≤r<b.
7
on o 1
ity
dividend remainder
rs e -W
quotient
rs
g
4
Notation:
r
R K 31
• 𝑑𝑑𝑑𝑑𝑑𝑑: ℤ × ℤ∗ → ℤ
𝑑𝑑𝑑𝑑𝑑𝑑 𝑎𝑎, 𝑏𝑏 ≔ the unique quotient, when 𝑎𝑎 is the dividend and 𝑏𝑏 the divisor
TH
G
U
(more commonly denoted by 𝑎𝑎 𝑑𝑑𝑑𝑑𝑑𝑑 𝑏𝑏 )
ye .
M
• 𝑚𝑚𝑚𝑚𝑚𝑚: ℤ × ℤ∗ → ℤ
𝑚𝑚𝑚𝑚𝑚𝑚 𝑎𝑎, 𝑏𝑏 ≔ the unique remainder, when 𝑎𝑎 is the dividend and 𝑏𝑏 the divisor
(more commonly denoted by 𝑎𝑎 𝑚𝑚𝑚𝑚𝑚𝑚 𝑏𝑏 )
19 ive u )
20 n io (c
𝑎𝑎 = 𝑞𝑞𝑞𝑞 + 𝑟𝑟 → gcd 𝑎𝑎, 𝑏𝑏 = gcd 𝑏𝑏, 𝑟𝑟 .
Proof:
7
on o 1
ity
Let 𝑎𝑎, 𝑏𝑏, 𝑞𝑞, 𝑟𝑟 be arbitrary integers, and assume 𝑎𝑎 = 𝑞𝑞𝑞𝑞 + 𝑟𝑟.
rs e -W
rs
Claim 1: Every divisor of 𝑎𝑎, 𝑏𝑏 also divides 𝑏𝑏, 𝑟𝑟.
g
4
r
Indeed, 𝑟𝑟 = 𝑎𝑎 + −𝑞𝑞 𝑏𝑏 (𝑟𝑟 is an integer combination of 𝑎𝑎, 𝑏𝑏).
R K 31
Claim 2: Every divisor of 𝑏𝑏, 𝑟𝑟 also divides 𝑎𝑎, 𝑏𝑏.
TH
G
U
Indeed, 𝑎𝑎 is an integer combination of 𝑏𝑏, 𝑟𝑟. ∎
ye .
M
Euclidean Algorithm
(for finding 𝐠𝐠𝐠𝐠𝐠𝐠 𝒂𝒂, 𝒃𝒃 , when 𝒂𝒂 ≥ 𝒃𝒃 ≥ 𝟎𝟎 and 𝒂𝒂 > 𝟎𝟎)
gcd 𝑎𝑎, 𝑏𝑏
- If 𝑏𝑏 = 0, return 𝑎𝑎.
- else, return gcd(𝑏𝑏, 𝑎𝑎 𝑚𝑚𝑚𝑚𝑚𝑚 𝑏𝑏)
25forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
Raphael’s “School of(c)
Athens” (1509) Ryerson University, 2019
K. Georgiou,
(Vatican’s Apostolic Palace)
The Euclidean Algorithm
(for finding GCDs)
a = q ⋅b + r
Example: Find GCD (−4410,−5005)
19 ive u )
and a,b not both 0
20 n io (c
GCD (−4410,−5005) = GCD(5005,4410) ⇒
GCD (a, b) = GCD (b, r )
7
on o 1
ity
Sign and order do not matter
rs e -W
rs
Apply repeatedly previous theorem, performing long division
g
4
that is, if 5005 = q ⋅ 4410 + r then GCD (5005,4410) = GCD (4410, r )
r
R K 31
Solution: 5005 = (1) ⋅ 4410 + 595 GCD (5005,4410) = GCD (4410,595)
TH
G
U
4410 = (7 ) ⋅ 595 + 245
ye .
M
19 ive u )
20 n io (c
Definition: (Floor of real number x)
⌊𝑥𝑥⌋: =largest integer which is no more than 𝑥𝑥.
7
on o 1
ity
rs e -W
⌊𝑥𝑥⌋ = 𝑛𝑛 ⇔ 𝑛𝑛 ∈ ℤ ∧ 𝑛𝑛 ≤ 𝑥𝑥 < 𝑛𝑛 + 1
rs
g
4
r
Examples:
R K 31 1/3 = 0, −4 = −4, 𝜋𝜋 = 3
TH
G
U
ye .
M
⌈𝑥𝑥⌉ = 𝑛𝑛 ⇔ 𝑛𝑛 ∈ ℤ ∧ 𝑛𝑛 − 1 < 𝑥𝑥 ≤ 𝑛𝑛
19 ive u )
20 n io (c
Theorem:
For all integers 𝑛𝑛 and positive integers 𝑑𝑑
7
𝒏𝒏 𝒅𝒅𝒅𝒅𝒅𝒅 𝒅𝒅 = 𝒏𝒏/𝒅𝒅
on o 1
ity
𝒏𝒏 𝒎𝒎𝒎𝒎𝒎𝒎 𝒅𝒅 = 𝒏𝒏 − 𝒅𝒅 𝒏𝒏/𝒅𝒅
rs e -W
rs
g
4
Proof (sketch):
r
R K 31
Let 𝑛𝑛 be an arbitrary integer and 𝑑𝑑 be an arbitrary positive integer.
TH
By correctness of division, there exist (unique) integers 𝑞𝑞, 𝑟𝑟, such that
G
U
𝑛𝑛 = 𝑑𝑑 ⋅ 𝒒𝒒 + 𝒓𝒓, 0 ≤ 𝑟𝑟 < 𝑑𝑑
ye .
M
19 ive u )
Definition Integers 𝑎𝑎, 𝑏𝑏 are called relatively prime
20 n io (c
(co-prime) if gcd 𝑎𝑎, 𝑏𝑏 = 1.
7
on o 1
ity
rs e -W
Examples: gcd 3,5 = 1, gcd 10,11 = 1 , gcd 5,16 = 1
rs
g
4
r
Theorem:
R K 31
TH
If 1 is an integer combination of 𝑎𝑎, 𝑏𝑏, then 𝑎𝑎, 𝑏𝑏 are coprime.
G
U
Proof:
ye .
M
ity
rs e -W
rs
g
4
r
Modular Arithmetic
R K 31
TH
G
U
ye .
M
30forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Motivation
19 ive u )
20 n io (c
Think of 3 digit integer, and call it x (example 587)
7
on o 1
ity
rs e -W
rs
Reorder it’s digits anyway you like and call the result y (example 875)
g
4
r
R K 31
Find the number |x-y|, and say it is represented with digits a,b,c.
TH
G
U
(example 875-587=288, so a,b,c are 2,8,8)
ye .
M
Motivation 31forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
slide
Congruences – Modular Arithmetic
Motivation: What day will it be in 2 days from now?
19 ive u )
20 n io (c
… in 9 days from now?
7
… in 16 days from now?
on o 1
ity
rs e -W
… in 700016 days from now?
rs
g
Definition: For all integers 𝑎𝑎, 𝑏𝑏, and positive integer 𝑚𝑚, we say that
4
r
R K 31
𝒂𝒂 is congruent to 𝒃𝒃 modulo m iff 𝑚𝑚|(𝑎𝑎 − 𝑏𝑏)
TH
G
U
Notation: We denote that 𝑎𝑎 is congruent to 𝑏𝑏 modulo m by a ≡ b(mod m )
We denote that 𝑎𝑎 is NOT congruent to 𝑏𝑏 modulo m by a ≡ b(mod m )
ye .
M
19 ive u )
20 n io (c
there exist integer 𝑞𝑞 with a = b + m ⋅ q iff a ≡ b(mod m ) .
7
Proof: a ≡ b mod m is equivalent to 𝑚𝑚|(𝑎𝑎 − 𝑏𝑏),
on o 1
ity
rs e -W
which is equivalent to that there exist integer q with a − b = m ⋅ q .
rs
g
4
r
R K 31
Lemma: For all integers 𝑎𝑎, 𝑏𝑏, and positive integer 𝑚𝑚, we have that
(⇐) Division of 𝑏𝑏 with 𝑚𝑚 gives unique quotient p and remainder 𝑟𝑟 < 𝑚𝑚 with b = m⋅ p + r
a ≡ b mod m implies that there exist integer 𝑞𝑞 with a − b = m ⋅ q .
Hence, a = b + m ⋅ q = m ⋅ p + r + m ⋅ q = m ⋅ ( p + q ) + r , which is exactly what
Sharing and/or posting online this manuscript, or parts of it, are strictly forbidden.
we wanted (why?).
(c) K. Georgiou, Ryerson University, 2019
Applications - Implications
Lemma: For all integers 𝑎𝑎, 𝑏𝑏, and positive integer 𝑚𝑚, we have that
19 ive u )
20 n io (c 7
Important Implication - Example: Consider the set of integers:
on o 1
ity
rs e -W
{...,−12,−11,−10,−9,−8,−7,−6,−5,−4,−3,−2,−1,0,1,2,3,4,5,6,7,8,9,10,11,12,...}
rs
g
4
r
R K 31
When dividing with 6, there are only six different possibilities for remainders.
19 ive u )
20 n io (c
Examples
7
on o 1
ity
−3 ≡ 2 𝑚𝑚𝑚𝑚𝑚𝑚 5 , 18 ≡ 0 𝑚𝑚𝑚𝑚𝑚𝑚 6
rs e -W
rs
g
4
Theorem ∀𝑛𝑛 ∈ ℤ>0 , ∀𝑎𝑎 ∈ ℤ, ∃! 𝑟𝑟 ∈ 0,1, … , 𝑛𝑛 − 1 ,
r
R K 31
𝑎𝑎 ≡ 𝑟𝑟 𝑚𝑚𝑚𝑚𝑚𝑚 𝑛𝑛 .
TH
G
U
Proof
ye .
M
Definition
The unique 𝑟𝑟 above is called the least positive residue.
35forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Equivalence Relations
19 ive u )
20 n io (c
Theorem: For all integers a,b, and positive integer m,
Reflixivity a ≡ a (mod m )
7
on o 1
ity
Symmetry a ≡ b(mod m ) ↔ b ≡ a (mod m )
rs e -W
rs
Transitivity (a ≡ b(mod m ) ∧ b ≡ c(mod m )) → a ≡ c(mod m )
g
4
r
R K 31
Proof: (sketch)
TH
G
U
…of reflixivity: m | ( a − a ) .
ye .
M
…of symmetry: (m | (a − b) ) ↔ (m | (b − a ) ) .
19 ive u )
i) there exist integer 𝑞𝑞 with a = b + m ⋅ q .
20 n io (c
ii) m | (a − b )
7
on o 1
ity
iii) 𝑎𝑎, 𝑏𝑏 have same remainder when divided with m.
rs e -W
rs
g
Theorem: For all integers 𝑎𝑎, 𝑏𝑏, 𝑎𝑎𝑎, 𝑏𝑏𝑏 and 𝑚𝑚 > 0, we have
4
r
R K 31
a ≡ a ' (mod m ) (i) a + b ≡ a '+b' (mod m )
TH
G (ii) a − b ≡ a '−b' (mod m )
U
imply
b ≡ b' (mod m )
(iii) a ⋅ b ≡ a '⋅b' (mod m )
ye .
M
Similarly we show (ii) and (iii) … Sharing and/or posting online this manuscript, or parts of it, are strictly forbidden.
(c) K. Georgiou, Ryerson University, 2019
Examples on Congruences
19 ive u )
20 n io (c
Example For all integers 𝑥𝑥 show that
7
on o 1
4𝑥𝑥 ≡ 1 𝑚𝑚𝑚𝑚𝑚𝑚 7 iff 𝑥𝑥 ≡ 2 𝑚𝑚𝑚𝑚𝑚𝑚 7
ity
rs e -W
Solution:
rs
Let 𝑥𝑥 be arbitrary.
g
4
⇒ If 4𝑥𝑥 ≡ 1 𝑚𝑚𝑚𝑚𝑚𝑚 7 , then 8𝑥𝑥 ≡ 2 𝑚𝑚𝑚𝑚𝑚𝑚 7 .
r
R K 31
But 8𝑥𝑥 ≡ 7𝑥𝑥 + 𝑥𝑥 ≡ 𝑥𝑥 (𝑚𝑚𝑚𝑚𝑚𝑚 7).
TH
G
U
⇐ If 𝑥𝑥 ≡ 2 𝑚𝑚𝑚𝑚𝑚𝑚 7 , then 4𝑥𝑥 ≡ 8 ≡ 1 𝑚𝑚𝑚𝑚𝑚𝑚 7 .
ye .
M
38forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
More Examples (2)
1001
Example: Find the second to last digit of 46 .
19 ive u )
Solution: Question asks to find the second to last digit of 461001 (mod 100 ) .
20 n io (c 7
We observe that 46 ≡ 46 (mod 100 )
on o 1
This shows that
ity
rs e -W
46 2 ≡ 2116 ≡ 16 (mod 100 ) 46 n +5 ≡ 46 n (mod 100 )
rs
463 ≡ 97336 ≡ 36(mod 100 )
g
4
for n≥2.
r
R K 31
46 4 ≡ 4477456 ≡ 56(mod 100 ) This shows that
TH
G
U
465 ≡ 205962976 ≡ 76(mod 100 ) 46 n +5⋅k ≡ 46 n (mod 100 )
ye .
M
Sharing and/or posting online this manuscript, or parts of it, are strictly forbidden.
(c) K. Georgiou, Ryerson University, 2019
More Examples (2)
1001
Example: Find the second to last digit of 46 .
19 ive u )
Solution: Question asks to find the second to last digit of 461001 (mod 100 ) .
20 n io (c 7
We observe that 46 ≡ 46 (mod 100 )
on o 1
This shows that
ity
rs e -W
46 2 ≡ 2116 ≡ 16 (mod 100 ) 46 n +5 ≡ 46 n (mod 100 )
rs
463 ≡ 97336 ≡ 36(mod 100 )
g
4
for n≥2.
r
R K 31
46 4 ≡ 4477456 ≡ 56(mod 100 ) This shows that
TH
G
U
465 ≡ 205962976 ≡ 76(mod 100 ) 46 n +5⋅k ≡ 46 n (mod 100 )
ye .
M
19 ive u )
20 n io (c
Example Find the last digit of 1312 .
7
on o 1
ity
rs e -W
rs
Solution:
g
4
r
R K 31
1312 ≡ 312 (𝑚𝑚𝑚𝑚𝑚𝑚 10)
TH
G
U
32 ≡ 9 ≡ −1 (𝑚𝑚𝑚𝑚𝑚𝑚 10)
ye .
M
19 ive u )
20 n io (c
Already Proved
7
on o 1
ity
For all integers 𝑎𝑎, 𝑏𝑏 and positive integer 𝑚𝑚, the following are
rs e -W
equivalent
rs
g
• 𝑎𝑎 ≡ 𝑏𝑏 (𝑚𝑚𝑚𝑚𝑚𝑚 𝑚𝑚)
4
r
R K 31
• 𝑎𝑎, 𝑏𝑏 have the same remainder when divided by 𝑚𝑚
TH
G
U
• 𝑚𝑚|(𝑎𝑎 − 𝑏𝑏)
• 𝑎𝑎 = 𝑞𝑞𝑞𝑞 + 𝑏𝑏, for some integer 𝑞𝑞.
ye .
M
Already defined
𝑏𝑏 is the least positive residue of 𝑎𝑎 (𝑚𝑚𝑚𝑚𝑚𝑚 𝑚𝑚) if
𝑎𝑎 ≡ 𝑏𝑏 (𝑚𝑚𝑚𝑚𝑚𝑚 𝑚𝑚) and 0 ≤ 𝑏𝑏 < 𝑚𝑚.
42forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Simplifying Powers
19 ive u )
20 n io (c
Example Find the last digit of 22012 .
(Find least positive residue of 22012 𝑚𝑚𝑚𝑚𝑚𝑚 10 )
7
on o 1
ity
rs e -W
Solution: 21 ≡ 𝟐𝟐(𝒎𝒎𝒎𝒎𝒎𝒎 𝟏𝟏𝟏𝟏)
rs
g
4
22 ≡ 4(𝑚𝑚𝑚𝑚𝑚𝑚 10)
r
R K 31
23 ≡ 22 ⋅ 2 = 4 ⋅ 2 ≡ 8(𝑚𝑚𝑚𝑚𝑚𝑚 10)
TH
G
U
24 ≡ 23 ⋅ 2 = 8 ⋅ 2 ≡ 16 ≡ 6(𝑚𝑚𝑚𝑚𝑚𝑚 10)
25 ≡ 24 ⋅ 2 = 6 ⋅ 2 ≡ 12 ≡ 𝟐𝟐(𝒎𝒎𝒎𝒎𝒎𝒎 𝟏𝟏𝟏𝟏)
ye .
M
19 ive u )
20 n io (c
Example Find the remainder when
7
172018 is divided by 5.
on o 1
ity
rs e -W
Solution:
rs
g
4
Least positive residue of 172018 𝑚𝑚𝑚𝑚𝑚𝑚 5 =?
r
R K 31
Or equivalently of 22018 𝑚𝑚𝑚𝑚𝑚𝑚 5 =?
TH
G
U
21 ≡ 2(𝑚𝑚𝑚𝑚𝑚𝑚 5)
ye .
M
22 ≡ 4 (𝑚𝑚𝑚𝑚𝑚𝑚 5)
23 ≡ 22 ⋅ 2 ≡ 4 ⋅ 2 ≡ 8 ≡ 3 (𝑚𝑚𝑚𝑚𝑚𝑚 5)
2𝟒𝟒 ≡ 23 ⋅ 2 ≡ 3 ⋅ 2 ≡ 6 ≡ 𝟏𝟏 (𝒎𝒎𝒎𝒎𝒎𝒎 𝟓𝟓)
Hence, 22018 = 24⋅504+2 ≡ 24 504 22 ≡ 1504 22 ≡ 4 𝑚𝑚𝑚𝑚𝑚𝑚 5 .
44forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
19 ive u )
20 n io (c 7
on o 1
ity
rs e -W
rs
g
4
Rules of Divisibility
r
R K 31
TH
(Time Permitting)
G
U
ye .
M
45forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
High Level Goal
19 ive u )
20 n io (c
Given 𝑛𝑛, 𝑑𝑑: Find conditions regarding 𝑛𝑛’s digits that
7
on o 1
ity
guarantee divisibility by 𝑑𝑑?
rs e -W
rs
g
4
r
R K 31
Example: Is 428374567810 divisible by 10?
TH
G
U
ye .
M
Observation:
Integer 𝑛𝑛 is divisible by 10 iff it’s right-most digit is 0.
46forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019
Divisibility by 2
19 ive u )
20 n io (c
Example: Is 428374567817 divisible by 2?
7
on o 1
ity
rs e -W
Proposition:
rs
𝑛𝑛 = 𝑎𝑎𝑘𝑘 10𝑘𝑘 + ⋯ + 𝑎𝑎2 102 + 𝑎𝑎1 101 + 𝑎𝑎0 100
g
4
r
R K 31
is divisible by 2 iff 𝑎𝑎0 is even.
TH
G
U
ye .
Proof: Will find least positive residue of 𝑛𝑛(𝑚𝑚𝑚𝑚𝑚𝑚 2).
M
19 ive u )
20 n io (c
Example: Is 428374567815 divisible by 5?
7
on o 1
ity
rs e -W
Proposition:
rs
𝑛𝑛 = 𝑎𝑎𝑘𝑘 10𝑘𝑘 + ⋯ + 𝑎𝑎2 102 + 𝑎𝑎1 101 + 𝑎𝑎0 100
g
4
r
R K 31
is divisible by 5 iff 𝑎𝑎0 is 0 or 5.
TH
G
U
ye .
Proof: Will find least positive residue of 𝑛𝑛(𝑚𝑚𝑚𝑚𝑚𝑚 5).
M
19 ive u )
20 n io (c
Example: Is 428374567814 divisible by 4?
7
Answer: No because 𝟒𝟒 ∤ 𝟏𝟏𝟏𝟏.
on o 1
ity
rs e -W
Proposition:
rs
𝑛𝑛 = 𝑎𝑎𝑘𝑘 10𝑘𝑘 + ⋯ + 𝑎𝑎2 102 + 𝑎𝑎1 101 + 𝑎𝑎0 100
g
4
r
R K 31
is divisible by 4 iff 𝑎𝑎1 101 + 𝑎𝑎0 is divisible by 4.
TH
G
U
ye .
Proof: Will find least positive residue of 𝑛𝑛(𝑚𝑚𝑚𝑚𝑚𝑚 4).
M
19 ive u )
20 n io (c
Example: Is 428374567814 divisible by 3?
7
Answer: 𝟒𝟒 + 𝟐𝟐 + 𝟖𝟖 + 𝟑𝟑 + 𝟕𝟕 + 𝟒𝟒 + 𝟓𝟓 + 𝟔𝟔 + 𝟕𝟕 + 𝟖𝟖 + 𝟏𝟏 + 𝟒𝟒 = 𝟓𝟓𝟓𝟓 and 𝟑𝟑 ∤ 𝟓𝟓𝟓𝟓
on o 1
ity
Proposition:
rs e -W
rs
𝑛𝑛 = 𝑎𝑎𝑘𝑘 10𝑘𝑘 + ⋯ + 𝑎𝑎2 102 + 𝑎𝑎1 101 + 𝑎𝑎0 100
g
4
r
R K 31
is divisible by 3 iff 𝑎𝑎𝑘𝑘 + 𝑎𝑎𝑘𝑘−1 + ⋯ + 𝑎𝑎1 + 𝑎𝑎0 is divisible by 3.
TH
G
U
Proof: Will find least positive residue of 𝑛𝑛(𝑚𝑚𝑚𝑚𝑚𝑚 3).
ye .
M
19 ive u )
20 n io (c
Example: Is 428374567814 divisible by 𝟗𝟗?
7
Answer: 𝟒𝟒 + 𝟐𝟐 + 𝟖𝟖 + 𝟑𝟑 + 𝟕𝟕 + 𝟒𝟒 + 𝟓𝟓 + 𝟔𝟔 + 𝟕𝟕 + 𝟖𝟖 + 𝟏𝟏 + 𝟒𝟒 = 𝟓𝟓𝟓𝟓 and 𝟗𝟗 ∤ 𝟓𝟓𝟓𝟓
on o 1
ity
Proposition:
rs e -W
rs
𝑛𝑛 = 𝑎𝑎𝑘𝑘 10𝑘𝑘 + ⋯ + 𝑎𝑎2 102 + 𝑎𝑎1 101 + 𝑎𝑎0 100
g
4
r
R K 31
is divisible by 𝟗𝟗 iff 𝑎𝑎𝑘𝑘 + 𝑎𝑎𝑘𝑘−1 + ⋯ + 𝑎𝑎1 + 𝑎𝑎0 is divisible by 𝟗𝟗.
TH
G
U
Proof: Will find least positive residue of 𝑛𝑛(𝑚𝑚𝑚𝑚𝑚𝑚 𝟗𝟗).
ye .
M
19 ive u )
20 n io (c
Proposition:
7
on o 1
ity
Let 𝑥𝑥 = 𝑎𝑎2 100 + 𝑎𝑎1 10 + 𝑎𝑎0 .
rs e -W
rs
Let 𝑦𝑦 = 𝑎𝑎1 100 + 𝑎𝑎0 10 + 𝑎𝑎2 .
g
4
r
Let 𝑥𝑥 − 𝑦𝑦 = 𝑏𝑏2 100 + 𝑏𝑏1 10 + 𝑏𝑏0 .
R K 31
Then 𝑏𝑏2 + 𝑏𝑏1 + 𝑏𝑏0 is divisible by 9.
TH
G
U
ye .
M
Example:
𝑥𝑥 = 587, 𝑦𝑦 = 875
𝑥𝑥 − 𝑦𝑦 = 288
2 + 8 + 8 = 18 = 0 𝑚𝑚𝑚𝑚𝑚𝑚 9
52forbidden.
Sharing and/or posting online this manuscript, or parts of it, are strictly
(c) K. Georgiou, Ryerson University, 2019