You are on page 1of 45

Discrete Mathematics

(Odd Semester 2021/2022)


Number Theory
Number Theory
 Terminology:
a  b (a divides b) if there is an integer c so
that b = ac (a, b integers; a  0)

5  10 karena 10=5.2

10=5.2 maka 5  10
Number Theory
 When a divides b :
a is a factor of b
b is a multiple of a
It is denoted with: a | b
The notation a | b means: a does not divide b
(the correct notation for “does not divide” will be
presented in class)
 Determine whether 3 | 7 and whether 3 | 12 ?
Properties of Divisibility
 For integers a, b, and c it is true that:
1. if a | b and a | c, then a | (b + c)
Example: 3 | 6 and 3 | 9, so 3 | 15.
2. if a | b, then a | bc for all integers c
Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, …
3. if a | b and b | c, then a | c
Example: 4 | 8 and 8 | 24, so 4 | 24.
Properties of Divisibility
1. Show that if a | b and b | a, where a and b
are integers, then a = b or a = -b.
2. Show that if a | b and b | c, then a | c.
3. Show that if a, b and c are integers such
that ac | bc, then a | b.
4. Show that if a | b and a | c,
then a | (b + c)
5. Show that if a | b, then a | bc for all
integers c
HW (choose 2 from 3,4,5)
Properties of Divisibility
1. Show that if a | b and b | a, where a and b
are integers, then a = b or a = -b.
ANSWER:
1. Prove (a | b  b | a)  (a = b  a = -b)
2. From 1, we assume (a | b  b | a)
3. Prove (a = b  a = -b)
4. From 2, we obtain a | b
5. From 2, we obtain b | a
a  b (a divides b) if there is an integer c
so that b = ac
6. From 4, we obtain b=ac, c integer
Properties of Divisibility
Primes
 A prime p: a positive integer greater than 1
whose only positive factors are 1 and p.
 A composite i: a positive integer that is greater
than 1 and is not prime.
 Example : The integer 7 is prime since its only
positive factors are 1 and 7, whereas the integer
9 is composite since it is divisible by 3.
Primes

 The Fundamental Theorem of Arithmetic : Every


positive integer can be written uniquely as the
product of primes.

• Note:
 The product can include zero, one or more than
one prime factors.
 It is customary to write this product in increasing
order of the primes for convenience and ease of
comparison among integers.
 This product is called: prime factorization
Primes
 Prime Factorization of Integers:
Examples:
15 = 3·5
48 = 2·2·2·2·3 = 24·3
17 = 17
100 =2·2·5·5 = 22·52
512 = 2·2·2·2·2·2·2·2·2 = 29
515 = 5·103
28 = 2·2·7
Division
 Terminology:
Let a be an integer and d a positive integer.
Then there are unique integers q and r, with 0 
r < d, such that a = dq + r.

17=3.5 + 2
 In the above equation:
d is called the divisor
a is called the dividend
q is called the quotient
r is called the remainder
Division
 Terminology - Example:
When we divide 17 by 5, we have:
17 = 53 + 2.
17 is the dividend
5 is the divisor
3 is the quotient
2 is the remainder
Division
 Another example:
What happens when we divide -11 by 3 ?
Note that the remainder cannot be negative.
-11 = 3(-4) + 1 (NOT: -11 = 3(-3) – 2)
-11 is the dividend
3 is the divisor
-4 is the quotient
1 is the remainder
Greatest Common Divisors
 The greatest common divisor of a and b is the
largest integer d such that d | a and d | b (for
a,b integers, not both zero).
 The greatest common divisor of a and b is
denoted by gcd(a, b).
 Examples:
– What is gcd(48, 72) ?
The positive common divisors of 48 and 72 are
1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24.
– What is gcd(19, 72) ?
The only positive common divisor of 19 and 72 is 1, so
gcd(19, 72) = 1.
Greatest Common Divisors
 There are 3 methods for finding the GCD(i,j):
1. Find the divisors of i and the divisors of j; create
the set of the common ones and pick the
greatest.
2. Use the prime factorization of i and j.
3. Use the Euclidean Algorithm (will be studied
later).
Greatest Common Divisors
 Two integers a and b are relatively prime if
gcd(a, b) = 1.
 Examples:
Are 15 and 28 relatively prime?
Yes, gcd(15, 28) = 1.
Are 55 and 28 relatively prime?
Yes, gcd(55, 28) = 1.
Are 35 and 28 relatively prime?
No, gcd(35, 28) = 7.
Relatively Prime Integers
 The integers a1, a2, …, an are pairwise
• relatively prime if gcd(ai, aj) = 1 whenever
1  i < j  n.
 Examples:
Are 15, 17, and 27 pairwise relatively prime?
No, because gcd(15, 27) = 3.
Are 15, 17, and 28 pairwise relatively prime?
Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and
gcd(17, 28) = 1.
Greatest Common Divisors
 Using prime factorizations for finding gcd(a,b):
• a = p1a1 p2a2 … pnan , b = p1b1 p2b2 …
pnbn , where p1 < p2 < … < pn and ai, bi  N for 1
in
• gcd(a, b) = p1min(a1, b1 ) p2min(a2, b2 ) … pnmin(an,
b )
n

• a = 60 =
Example: 22
3 1
51

b = 54 = 21 33 50
gcd(a, b) = 21 31 50 = 6
Least Common Multiples
 The least common multiple of the positive
integers a and b is the smallest positive integer
that is divisible by both a and b.
 The least common multiple of a and b is denoted
by lcm(a, b).
 Examples:
lcm(3, 7) = 21
lcm(4, 6) = 12
lcm(5, 10) = 10
Least Common Multiples
 Using prime factorizations to find lcm(a,b):
• a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn ,
• where p1 < p2 < … < pn and ai, bi  N for 1  i 
n
• lcm(a, b) = p1max(a1, b1) p2max(a2, b2 ) … pnmax(an, bn )

• Example:
a = 60 = 22 31 51

b = 54 = 21 33 50
lcm(a, b) = 22 33 51 = 4275 = 540
GCD and LCM

a = 60 = 22 31 51

b = 54 = 21 33 50

gcd(a, b) = 21 31 50 =6

lcm(a, b) = 22 33 51 = 540

Theorem: ab = gcd(a,b)lcm(a,b)


Modular Arithmetic

9 mod 4 = 1
9 mod 3 = 0
9 mod 10 = 9
-13 mod 4 = 3
Congruences
 a is congruent to b modulo m if m divides (a – b);
(a,b integers; m positive integer)
 The notation a  b (mod m) is used to indicate that
a is congruent to b modulo m.
 This means that:
a  b (mod m) if and only if a mod m = b mod m.
 Examples:
Determine whether 17 is congruent to 5 modulo 6
and whether 24 is congruent to 14 modulo 6.
In other words, Is it true that 17  5 (mod 6) ?
Yes, because 6 | (17 – 5) or 6 | 12.
Congruences
Congruences

 Is it true that 24  14 (mod 6) ?


No, because 6 is not divisible by (24 – 14) or 6 is not
divisible by 10.
 Examples : For which integers z is it true that z 
12 (mod 10)?
It is true for any z{…,-28, -18, -8, 2, 12, 22, 32, …}
 Theorem: The integers a and b are congruent
modulo m if and only if there is an integer k such
that a = b + km (m positive integer).
 32  12 (mod 10)
 10 | 20 a|b b=a.c…. 10|0 0=10.0
Congruences
• Theorem (Two Properties of congruencies):
If a  b mod m;
c  d mod m,
then:
1) a + c  (b + d) mod m; m positive integer
2) ac  bd mod m; m positive integer
Congruences
Congruences
Congruences
Congruences
 Example :
 Since 7  2 (mod 5) and 11  1 (mod 5), it follows
that :
1. a + c  b + d (mod m) or 7 + 11  2 + 1 (mod 5)
or 18  3 (mod 5).
2. ac  bd (mod m) or 7.11  2.1 (mod 5) or 77  2
(mod 5).
Congruences
• Proof:
– Given: a  b (mod m); c  d (mod m)
– That implies (using theorem):
there are integers s,t such that:
a = b + sm and c = d + tm.
– Therefore:
a + c = (b + sm) + (d + tm) = (b + d) + m(s + t);
ac = (b + sm)(d + tm) = bd + m(bt + ds + stm);
So: a + c  b + d (mod m);
ac  bd (mod m).
Congruences
1.Show that if n|m, where n and m are positive
integers greater than 1, and if a  b mod m,
where a and b are integers, then a  b mod n
2. Show that if a,b, c and m are integers
such that m ≥ 2, c > 0, and a  b mod m,
then ac  bc (mod mc)
Applications of Number Theory
(Applications of Primes and
Modulo)
Applications of Primes and Modulo
 Primes and modulo are used in:
1. Hashing functions
2. Generation of pseudorandom numbers
3. Cryptology
4. ISBN
5. Chinese Remainder Theorem
Cryptology
 Cryptology is the study of secret messages
 Cryptology involves : encryption (encoding, making
a secret message), and decryption (decoding,
breaking the secret message)
 One of the earliest known uses of cryptology was
by Julius Caesar.
 He made messages secret by shifting each letter
three letters forward in the alphabet (sending the
last three letters of the alphabet to the first three).
 Example :The letter B is sent to E and the letter X
is sent to A.
Cryptology
 To express encryption process mathematically, first
replace each letter by an integer from 0 to 25, based
on its position in the alphabet.
 For example, replace A by 0, K by 10, and Z by 25.
 Caesar’s encryption method can be represented by the
function f that assigns t the nonnegative integer p, p
25, the integer f(p) in the set {0, 1, 2, …, 25} with
f(p) = (p + 3) mod 26
In the encrypted of the message, the letter
represented by p is replaced with the letter
represented by (p + 3) mod 26
Cryptology
 Example :
 What is the secret message produced from the message
“MEET YOU IN THE PARK” using the Caesar cipher ?
 Solution : First replace the letters in the message with
the numbers. This produces
12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10
 Now replace each of these numbers p by f(p) = (p+3)
mod 26. This gives
15 7 7 22 1 17 23 11 16 22 10 7 18 3 20 13
 Translating this back to the letters produces the
encrypted message “PHHW BRX LQ WKH SDUN”.
Cryptology

 To recover the original message from a secret


message encrypted by the Caesar chiper, the
function f-1, the inverse of f, sends an integer p
from {0, 1, 2, …, 25} to f-1 (p) = (p-3) mod 26.
 In other words, to find the original message, each
letter is shifted back three letters in the alphabet,
with the first three letters sent to the last three
letters of the alphabet.
 The process of determining the original message
from encrypted message is called decryption.
Cryptology

 Instead of shifting each letter by 3, we can shift


each letter by k, so that :
f(p) = (p + k) mod 26.
 Such a cipher is called a shift cipher.
 The decryption can be carried out using
f-1 (p) = (p - k) mod 26.
 Shift cipher can be enhanced to provide a high
level of security.
Cryptology
 One approach that slightly enhances the security is
to use a function of the form :
f(p) = (ap + b) mod 26, where a and b are
integers.
 Example : What the letter replaces the letter K
when the function f(p) = (7p + 3) mod 26 is used
for encryption ?
 Solution : First, note that 10 represent K. Then,
using the encryption function specified, it follows
that f(10) = (7.10 + 3) mod 26 = 21. Since 21
represents V, K is replaced by V in the encrypted
message.
Cryptology
 To recover the original message from a secret
message encrypted by the previous function,
what is the inverse function f-1(the inverse of f)
?
 Details of this function will be discussed in
class.
 There are many more sophisticated encryption
method which are not discussed here (will be
discussed in the course of computer security
(Keamanan Komputer)).
Cryptology

 Encrypt the alphabet A by translating the


letters into numbers, applying the
encryption function : f(p) = (3p + 7)
mod 26 and then decrypt the result into
the original alphabet !
Chinese Remainder Theorem

 Let m1, m2, …, mn be pairwise relatively prime


positive integers. The system
x  a1 (mod m1)
x  a2 (mod m2)
.
x  an (mod mn)
has a unique solution modulo m = m1m2…mn. (That
is, there is a solution x with 0  x  m, and all other
solutions are congruent modulo m to this solution).
Chinese Remainder Theorem

 Details of how to construct a simultaneous


solution for this problem will be presented in
class.
 Example :
What are the solutions of the systems of
congruences
x  2 (mod 3)
x  3 (mod 5)
x  2 (mod 7) ?
Chinese Remainder Theorem

 What are the solutions of the systems of


congruences
x  2 (mod 3)
x  1 (mod 4)
x  3 (mod 5) ?

You might also like