Discrete Mathematics with ApplicationsMATH236
Dr. Hung P. Tong-Viet
School of Mathematics, Statistics and Computer ScienceUniversity of KwaZulu-NatalPietermaritzburg Campus
Semester 1, 2013
Tong-Viet (UKZN) MATH236 Semester 1, 2013 1 / 38
Table of contents
1 Exponentiation in Zm
2 Prime numbers
3 Euler φ-function
4 Fermat and Euler Theorems
Tong-Viet (UKZN) MATH236 Semester 1, 2013 2 / 38
Exponentiation in Zm
Square and mutiply
Many cryptosystems requires you to be able to compute things like
21351563 mod 3172
Use square and multiply algorithm:
Write the exponent as sum of powers of 2 (binary)
1563 = 210 + 29 + 24 + 23 + 2 + 1
Hence
21351563 = 2135210+29+24+23+2+1
= 2135210 · 21352
9 · 213524 · 21352
3 · 21352 · 2135
Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 38
Exponentiation in Zm
Square and multiply
Now 2135210
= (21352)29
so
21351563 = (21352)29 · 21352
9 · 213524 · 21352
3 · 21352 · 2135
It is easy to compute 21352 mod 3172 which is 61
So
21351563 ≡ (61)29 · 21352
9 · 213524 · 21352
3 · 21352 · 2135
≡ (61 · 2135)29 · 21352
4 · 213523 · 21352 · 2135
We now calculate 61 · 2135 ≡ 183 (mod 3172)
Begin the process over again, firstly, rewrite the term
(61 · 2135)29 ≡ 1832
9(mod 3172) = (1832)2
8
Continue in this fashion until we’re found the answer.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 38
Exponentiation in Zm
Square and multiply
21351563 ≡ (1832)28 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (1769)28 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (17692)27 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (1769)27 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (17692)26 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (1769)26 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (17692)25 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (17692)24 · 21352
4 · 213523 · 21352 · 2135 (mod 3172)
≡ (1769 · 2135)24 · 21352
3 · 21352 · 2135 (mod 3172)
≡ (61)23 · 21352
3 · 21352 · 2135 (mod 3172)
≡ (61 · 2135)23 · 21352 · 2135 (mod 3172)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 38
Exponentiation in Zm
Square and multiply
21351563 ≡ (183)22 · 21352 · 2135 (mod 3172)
≡ (183 · 2135)22 · 2135 (mod 3172)
≡ 61 · 2135 (mod 3172)≡ 183 (mod 3172)
Hence21351563 ≡ 183 (mod 3172)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 38
Prime numbers
Prime numbers
An integer p ≥ 2 is a prime if 1 and p are its only positive divisors
Every positive integer n can be written uniquely in the formn = pe1
1 pe22 · · · p
ekk ,
where pi are distinct prime numbers and ei are positive integers
Prime numbers play an important role throughout the rest of thiscourse, particularly when we consider public-key cryptography
Tong-Viet (UKZN) MATH236 Semester 1, 2013 7 / 38
Prime numbers
Prime numbers
Here are some prime numbers:
2 3 5 7 11 13 17 19 23 2931 37 41 43 47 53 59 61 67 7173 79 83 89 97 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173179 181 191 193 197 199 211 223 227 229233 239 241 251 257 263 269 271 277 281283 293 307 311 313 317 331 337 347 349353 359 367 373 379 383 389 397 401 409419 421 431 433 439 443 449 457 461 463
Tong-Viet (UKZN) MATH236 Semester 1, 2013 8 / 38
Prime numbers
Prime numbers
Theorem
There are infinitely many prime numbers
Tong-Viet (UKZN) MATH236 Semester 1, 2013 9 / 38
Prime numbers
Prime numbers
Proof.
Suppose to the contrary that there are finitely many prime numbers
Suppose that there are k prime numbers: p1, p2, · · · , pk
Consider the number n = p1p2 · · · pk + 1
Clearly n > pi for all i = 1, 2, · · · , k so n 6= pi for all i
Since n is congruence to 1 modulo pi for all i = 1, 2, · · · , k , we seethat pi - n for all i
Thus n must be a prime number
However, this contradicts the assumption that there are only k suchprime numbers.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 10 / 38
Prime numbers
Prime numbers
The prime counting function π(n) is the number of prime numbersless than or equal to n.
π(2) = 1, π(3) = π(4) = 2, π(5) = π(6) = 3,π(7) = π(8) = π(9) = π(10) = 4
Theorem (Prime Number Theorem)
For large n,
π(n) ∼ n
ln(n)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 11 / 38
Euler φ-function
Euler φ-function
Definition
For a positive integer n, we denote by φ(n) the number of positive integersa for which 1 ≤ a ≤ n and gcd(a, n) = 1. The function φ is called theEuler φ-function.
Example
Since 1, 5, 7 and 11 are all the positive integers less than 12 and relativelyprime to 12, we have that φ(12) = 4.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 12 / 38
Euler φ-function
Euler φ-function
Table: Euler φ-function
n relatively prime integers in [1, n] φ(n)
1 1 12 1 13 1, 2 24 1, 3 25 1, 2, 3, 4 46 1, 5 27 1, 2, 3, 4, 5, 6 68 1, 3, 5, 7 49 1, 2, 4, 5, 7, 8 6
10 1, 3, 7, 9 4
Tong-Viet (UKZN) MATH236 Semester 1, 2013 13 / 38
Euler φ-function
Euler φ-function
Theorem
If p is a prime, then φ(p) = p − 1
Tong-Viet (UKZN) MATH236 Semester 1, 2013 14 / 38
Euler φ-function
Euler φ-function
Proof.
Let p be a prime
Then p is relatively prime to each of the numbers 1, 2, · · · , p − 1
So φ(p) = p − 1
Tong-Viet (UKZN) MATH236 Semester 1, 2013 15 / 38
Euler φ-function
Euler φ-function
Theorem
If p is a prime and k is a positive integer, then
φ(pk) = pk − pk−1 = pk(1− 1
p)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 16 / 38
Euler φ-function
Euler φ-function
Proof.
Let S = {1, 2, · · · , pk}Let A be a subset of S consisting of numbers which is not relativelyprime to pk
If a ∈ A, then a is a multiple of p. Thus A = {p, 2p, 3p, · · · , pk−1p}There are pk−1 such multiples, so |A| = pk−1
Clearly, S − A = A is the set of all positive integers in {1, 2, · · · , pk}which are relatively prime to pk
So
φ(pk) = |A| = |S | − |A| = pk − pk−1 = pk(1− 1
p)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 17 / 38
Euler φ-function
Euler φ-function
Example
φ(243) = φ(35) = 35(1− 1
3) = 162
φ(1024) = φ(210) = 210(1− 1
2) = 29 = 512
Tong-Viet (UKZN) MATH236 Semester 1, 2013 18 / 38
Euler φ-function
Mathematical Induction
Theorem (Principle of mathematical induction)
Let P(n) be a statement about n ∈ N. If
1 P(1) is true, and
2 For every k ∈ N, if P(k) is true, then P(k + 1) is true.
Then P(n) is true for all n ∈ N.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 19 / 38
Euler φ-function
Mathematical Induction
Example
Show that 13n − 1 is always divisible by 12 for all n ∈ N
Tong-Viet (UKZN) MATH236 Semester 1, 2013 20 / 38
Euler φ-function
Mathematical Induction
Proof.
Let P(n) be the statement ‘13n − 1 is divisible by 12’
For n = 1, we have 131 − 1 = 12 is divisible by 12, so P(1) is true
Suppose that P(k) is true for some integer k ≥ 1. Then
13k − 1 is divisible by 12
We will prove that P(k + 1) is true, i.e., 13k+1 − 1 is divisible by 12
We have 13k+1 − 1 = (13 · 13k − 13) + (13− 1) = 13(13k − 1) + 12
Since 13k − 1 is divisible by 12 by the induction hypothesis and 12 isdivisible by 12
We obtain that 13(13k − 1) + 12 is divisible by 12
Hence 13k+1 − 1 is divisible by 12 so P(k + 1) is true
Thus by mathematical induction, 13n − 1 is divisible by 12
Tong-Viet (UKZN) MATH236 Semester 1, 2013 21 / 38
Euler φ-function
Mathematical Induction
Example
Prove that 2n ≥ n + 1 for all n ∈ N. (∗)
Proof.
We have 21 = 2 ≥ 1 + 1 so (∗) is true for n = 1
Suppose that (∗) is true for n = k ≥ 1. Then 2k ≥ k + 1
We will prove that 2k+1 ≥ (k + 1) + 1 = k + 2
We have 2k+1 = 2 · 2k ≥ 2(k + 1) by induction hypothesis
We also have that 2(k + 1) = 2k + 2 ≥ k + 2 since k ≥ 1
So 2k+1 ≥ k + 2. Hence (∗) is true for k + 1.
By mathematical induction, we deduce that (∗) is true for all n ∈ N.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 22 / 38
Euler φ-function
Difference Rule
Lemma
Let A be a subset of a finite set S . Then |A| = |S − A| = |S | − |A|.
Proof.
Since S = A ∪ A and A ∩ A = ∅, we obtain that
|S | = |A ∪ A| = |A|+ |A|.
Hence |A| = |S | − |A|.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 23 / 38
Euler φ-function
Euler φ-function
Lemma
For k ≥ 1, let p1, p2, · · · , pk be distinct primes and let n be a positiveinteger that is divisible by pi for all i = 1, 2, · · · , k. Then the number ofintegers between 1 and n that are multiples of at least one of the integersii , 1 ≤ i ≤ k , i
n − nk∏
i=1
(1− 1
pi).
Tong-Viet (UKZN) MATH236 Semester 1, 2013 24 / 38
Euler φ-function
Euler φ-function
Proof.
We prove the lemma by induction on k
When k = 1, the integers between 1 and n that are multiples of p1 are
p1, 2p1, 3p1, · · · , (n
p1)p1
Hence, the number of integers between 1 and n that are multiples ofp1 is
n
p1= n − n(1− 1
p1) = n − n
k∏i=1
(1− 1
pi).
This establishes the base case
Tong-Viet (UKZN) MATH236 Semester 1, 2013 25 / 38
Euler φ-function
Euler φ-function
Proof.
Assume that k ≥ 2 and the result is true for all positive integers thatare divisible by k − 1 distinct primes
Let n be a positive integer that is divisible by k distinct primesp1, p2, · · · , pk
We wish to count the set S of all integers between 1 and n that aremultiples of at least one of the integers pi , 1 ≤ i ≤ k
We will use the Addition Rule
Let X be the set of all integers between 1 and n that are multiples ofat least one of the primes pi , 1 ≤ i ≤ k − 1
Let Y be the set of all integers between 1 and n that are multiples ofpk but not of pi for any i where 1 ≤ i ≤ k − 1
Tong-Viet (UKZN) MATH236 Semester 1, 2013 26 / 38
Euler φ-function
Euler φ-function
Proof.
By the Addition Rule, we have |S | = |X |+ |Y |By the induction hypothesis, we have
|X | = n − nk−1∏i=1
(1− 1
pi)
We next determine |Y |The set of all integers between 1 and n that are multiples of pk are
pk , 2pk , 3pk , · · · , (n
pk)pk
Hence, the number of integers between 1 and n that are multiples ofpk is n
pk
Tong-Viet (UKZN) MATH236 Semester 1, 2013 27 / 38
Euler φ-function
Euler φ-function
Proof.
Since gcd(pi , pk) = 1 for all 1 ≤ i < k , the multiples of pk that arenot multiples of pi for any i where 1 ≤ i ≤ k − 1 are those whosecoefficients (between 1 and n
pk) are not multiples of pi for any i ,
where 1 ≤ i ≤ k − 1.
Since npk
is divisible by pi for 1 ≤ i ≤ k − 1,
by induction hypothesis, the number of integers between 1 and npk
that are multiples of at least one of the integers pi , 1 ≤ i ≤ k − 1, is
n
pk− n
pk
k−1∏i=1
(1− 1
pi)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 28 / 38
Euler φ-function
Euler φ-function
Proof.
It follows that
|Y | =n
pk− (
n
pk− n
pk
k−1∏i=1
(1− 1
pi)) =
n
pk
k−1∏i=1
(1− 1
pi)
Hence
|S | = |X |+ |Y |= n − n
∏k−1i=1 (1− 1
pi) + n
pk
∏k−1i=1 (1− 1
pi)
= n − [n∏k−1
i=1 (1− 1pi
)](1− 1pk
)
= n − n∏k
i=1(1− 1pi
)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 29 / 38
Euler φ-function
Euler φ-function
Theorem
If n =∏k
i=1 peii , where p1, p2, · · · , pk are distinct primes and e1, e2, · · · , ek
are positive integers, then
φ(n) = nk∏
i=1
(1− 1
pk)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 30 / 38
Euler φ-function
Euler φ-function
Since n =∏k
i=1 peii , where p1, p2, · · · , pk are distinct primes, and
e1, e2, · · · , ek are positive integers
The only integers between 1 and n that are not relatively prime to nare those integers between 1 and n that are multiples of at least oneof the integers pi , 1 ≤ i ≤ k
By our previous lemma, the number of such integers is
n − nk∏
i=1
(1− 1
pi)
Hence, the result follows by applying the difference rule.
Tong-Viet (UKZN) MATH236 Semester 1, 2013 31 / 38
Euler φ-function
Euler φ-function
Example
φ(30) = φ(2 · 3 · 5) = 2 · 3 · 5(1− 12)(1− 1
3)(1− 15) = 8
φ(6) = 2 · 3(1− 12)(1− 1
3) = 2
φ(20) = 20(1− 12)(1− 1
5) and φ(9) = 9− 3 = 6
We have φ(180) = φ(22 · 32 · 5) = 22 · 32 · 5(1− 12)(1− 1
3)(1− 15) = 48
Tong-Viet (UKZN) MATH236 Semester 1, 2013 32 / 38
Euler φ-function
Euler φ-function
Theorem
If m and n are relatively prime integers and gcd(m, n) = 1, then
φ(mn) = φ(m)φ(n).
Tong-Viet (UKZN) MATH236 Semester 1, 2013 33 / 38
Euler φ-function
Euler φ-function
Proof.
Let m =∏k
i=1 peii and n =
∏k ′
i=1(p′i )e′i , where
p1, p2, · · · , pk , p′1, p′2, · · · , p′k are distinct primes since gcd(m, n) = 1
By the previous theorem, we have
φ(mn) = mn∏k
i=1(1− 1pi
)∏k ′
i=1(1− 1p′i
)
= m∏k
i=1(1− 1pi
)n∏k ′
i=1(1− 1p′i
)
= φ(m)φ(n)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 34 / 38
Euler φ-function
Euler φ-function
Example
We have φ(248832) = φ(210 · 35) = φ(210)φ(35) = 162 · 512 = 82944
Tong-Viet (UKZN) MATH236 Semester 1, 2013 35 / 38
Fermat and Euler Theorems
Fermat Theorem
Theorem (Fermat)
If a is a positive integer and p is a prime number, then
ap ≡ a (mod p)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 36 / 38
Fermat and Euler Theorems
Fermat Theorem
Proof.
We will prove this theorem by induction on a
If a = 1, then ap = 1p ≡ 1 = a (mod p) as wanted
Assume that for some integer a ≥ 1, we have
ap ≡ a (mod p)
We will prove that (a + 1)p ≡ a + 1 (mod p)
Consider the binomial expansion of (a + 1)p
Tong-Viet (UKZN) MATH236 Semester 1, 2013 37 / 38
Fermat and Euler Theorems
Fermat Theorem
Proof.
(a + 1)p =
p∑i=0
(p
i
)ai = 1 + pa + · · ·+ pap−1 + ap
Except the first and the last terms, every other term is divisible by p
So (a + 1)p ≡ ap + 1 (mod p)
By the induction hypothesis, we have ap ≡ a (mod p)
Thus(a + 1)p ≡ a + 1 (mod p)
Tong-Viet (UKZN) MATH236 Semester 1, 2013 38 / 38
Top Related