Uu 24 25 Discretemathematics 05
Uu 24 25 Discretemathematics 05
Discrete Mathematics
Fatih Temiz, PhD
fatih.temiz@uskudar.edu.tr
Definition
If a and b are integers with a ̸= 0, we say that a divides b if there is an
integer c such that
b
b = ac (or equivalently, if is an integer).
a
When a divides b, we say that a is a factor or divisor of b, and that b is a
multiple of a. The notation a | b denotes that a divides b. We write a ∤ b
when a does not divide b.
Definition
If a and b are integers with a ̸= 0, we say that a divides b if there is an
integer c such that
b
b = ac (or equivalently, if is an integer).
a
When a divides b, we say that a is a factor or divisor of b, and that b is a
multiple of a. The notation a | b denotes that a divides b. We write a ∤ b
when a does not divide b.
Example
7
3̸ | 7, because 3 is not an integer. However, 3 | 12 because 12 = 3 · 4.
Example
Let n and d be positive integers. How many positive integers not
exceeding n are divisible by d?
The positive integers divisible by d are all the integers of the form dk,
where k is a positive integer.
Example
Let n and d be positive integers. How many positive integers not
exceeding n are divisible by d?
The positive integers divisible by d are all the integers of the form dk,
where k is a positive integer.
Hence, the number of positive integers divisible by d that do not
exceed n equals the number of integers k with 0 < dk ≤ n, or with
0 < k ≤ dn .
Example
Let n and d be positive integers. How many positive integers not
exceeding n are divisible by d?
The positive integers divisible by d are all the integers of the form dk,
where k is a positive integer.
Hence, the number of positive integers divisible by d that do not
exceed n equals the number of integers k with 0 < dk ≤ n, or with
0 < k ≤ dn .
Therefore, there are dn positive integers not exceeding n that are
divisible by d.
Theorem
Let a, b, and c be integers, where a ̸= 0. Then
(i) If a | b and a | c, then a | (b + c).
(ii) If a | b, then a | bc for all integers c.
(iii) If a | b and b | c, then a | c.
Theorem
Let a, b, and c be integers, where a ̸= 0. Then
(i) If a | b and a | c, then a | (b + c).
(ii) If a | b, then a | bc for all integers c.
(iii) If a | b and b | c, then a | c.
Corollary
If a, b, c ∈ Z, where a ̸= 0, such that a | b and a | c, then
a | (mb + nc) whenever m, n ∈ Z.
a = dq + r .
a = dq + r .
Definition
In the equality given in the Division Algorithm, d is called the divisor, a is
called the dividend, q is called the quotient, and r is called the remainder.
This notation is used to express the quotient and remainder:
r = a mod d.
What are the quotient and remainder when 101 is divided by 11?
What are the quotient and remainder when 101 is divided by 11?
101 = 11 · 9 + 2
What are the quotient and remainder when 101 is divided by 11?
101 = 11 · 9 + 2
What are the quotient and remainder when 101 is divided by 11?
101 = 11 · 9 + 2
−11 = 3 · (−4) + 1.
Definition
If a and b are integers and m is a positive integer, then a is congruent to b
modulo m if m divides a − b. We use the notation a ≡ b (mod m) to
indicate that a is congruent to b modulo m. We say that a ≡ b (mod m)
is a congruence and that m is its modulus (plural moduli).
Definition
If a and b are integers and m is a positive integer, then a is congruent to b
modulo m if m divides a − b. We use the notation a ≡ b (mod m) to
indicate that a is congruent to b modulo m. We say that a ≡ b (mod m)
is a congruence and that m is its modulus (plural moduli).
Theorem
Let a and b be integers, and let m be a positive integer. Then a ≡ b
(mod m) if and only if a mod m = b mod m.
Theorem
Let a and b be integers, and let m be a positive integer. Then a ≡ b
(mod m) if and only if a mod m = b mod m.
Theorem
Let a and b be integers, and let m be a positive integer. Then a ≡ b
(mod m) if and only if a mod m = b mod m.
Theorem
Let m be a positive integer. The integers a and b are congruent modulo m
if and only if there is an integer k such that a = b + km.
Theorem
Let m be a positive integer. The integers a and b are congruent modulo m
if and only if there is an integer k such that a = b + km.
Theorem
Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then
Theorem
Let m be a positive integer. The integers a and b are congruent modulo m
if and only if there is an integer k such that a = b + km.
Theorem
Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then
18 = 7 + 11 ≡ 2 + 1 = 3 (mod 5)
and that
77 = 7 · 11 ≡ 2 · 1 = 2 (mod 5).
Corollary
Let m be a positive integer and let a and b be integers. Then
and
ab mod m = ((a mod m)(b mod m)) mod m.
Arithmetic Moduo m
Arithmetic Moduo m
a +m b = (a + b) mod m,
a ·m b = (a · b) mod m.
and
7 ·11 9 = (7 · 9) mod 11 = 63 mod 11 = 8.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
Operations in Zm
1 Addition is closed, i.e., for any a, b ∈ Zm , a + b ∈ Zm .
2 Addition is commutative, i.e., for any a, b ∈ Zm , a + b = b + a.
3 Addition is associative, i.e., for any a, b, c ∈ Zm ,
(a + b) + c = a + (b + c).
a + (m − a) = (m − a) + a = 0.
g 2 =g · g (mod N)
g 3 =g · g 2 (mod N)
4 3
g =g · g (mod N)
..
.
g A =g · g A−1 (mod N)
g 2 =g · g (mod N)
g 3 =g · g 2 (mod N)
4 3
g =g · g (mod N)
..
.
g A =g · g A−1 (mod N)
First observe that we can avoid using large amount of memory
g 2 =g · g (mod N)
g 3 =g · g 2 (mod N)
4 3
g =g · g (mod N)
..
.
g A =g · g A−1 (mod N)
First observe that we can avoid using large amount of memory
However if A is large, this algorithm is completely impractical. For
example, if A ≈ 21000 , then the naive algorithm would take longer
than the estimated age of the universe!
218 = 2 + 23 + 24 + 26 + 27
218 = 2 + 23 + 24 + 26 + 27
Further, since we only need these values modulo 1000, we never need
to store more than three digits.
i 0 1 2 3 4 5 6 7
i
32 (mod 1000) 3 9 81 561 721 841 281 961
Further, since we only need these values modulo 1000, we never need
to store more than three digits.
i 0 1 2 3 4 5 6 7
i
32 (mod 1000) 3 9 81 561 721 841 281 961
3 +24 +26 +27 3 4 6 7
3218 = 32+2 = 32 · 32 · 32 · 32 · 32
≡ 9 · 561 · 721 · 281 · 961 (mod 1000)
≡ 489 (mod 1000)
Definition
An integer p greater than 1 is called prime if the only positive factors of p
are 1 and p. A positive integer that is greater than 1 and is not prime is
called composite.
Definition
An integer p greater than 1 is called prime if the only positive factors of p
are 1 and p. A positive integer that is greater than 1 and is not prime is
called composite.
Definition
An integer p greater than 1 is called prime if the only positive factors of p
are 1 and p. A positive integer that is greater than 1 and is not prime is
called composite.
Example
100 = 22 52 , 641 = 641, 999 = 33 · 37, 1024 = 210
Theorem
√
If n is a composite integer, then n has a prime divisor less than or equal to n.
Theorem
√
If n is a composite integer, then n has a prime divisor less than or equal to n.
Theorem
There are infinitely many primes.
Theorem
√
If n is a composite integer, then n has a prime divisor less than or equal to n.
Theorem
There are infinitely many primes.
Definition
Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
Definition
Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
Definition
Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
Definition
Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
Definition
Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1
whenever 1 ≤ i < j ≤ n.
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1
whenever 1 ≤ i < j ≤ n.
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1
whenever 1 ≤ i < j ≤ n.
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1
whenever 1 ≤ i < j ≤ n.
Definition
The integers a and b are relatively prime if gcd(a, b) = 1.
Definition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1
whenever 1 ≤ i < j ≤ n.
Another way to find the greatest common divisor of two positive integers is
to use the prime factorizations of these integers.
Another way to find the greatest common divisor of two positive integers is
to use the prime factorizations of these integers.
Suppose that the prime factorizations of the positive integers a and b are
Another way to find the greatest common divisor of two positive integers is
to use the prime factorizations of these integers.
Suppose that the prime factorizations of the positive integers a and b are
Another way to find the greatest common divisor of two positive integers is
to use the prime factorizations of these integers.
Suppose that the prime factorizations of the positive integers a and b are
Definition
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).
Definition
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).
Definition
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).
Definition
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).
Theorem
Let a and b be positive integers. Then
287 = 91 · 3 + 14
287 = 91 · 3 + 14
287 = 91 · 3 + 14
287 = 91 · 3 + 14
287 = 91 · 3 + 14
91 = 14 · 6 + 7
91 = 14 · 6 + 7
91 = 14 · 6 + 7
14 = 7 · 2
Euclidean Algorithm
Lemma
Let a = bq + r , where a, b, q, and r are integers. Then gcd(a, b) =
gcd(b, r ).
Euclidean Algorithm
Lemma
Let a = bq + r , where a, b, q, and r are integers. Then gcd(a, b) =
gcd(b, r ).
r0 = r1 q1 + r2 , 0 ≤ r2 < r1
r1 = r2 q2 + r3 , 0 ≤ r3 < r2
..
.
rn−2 = rn−1 qn−1 + rn , 0 ≤ rn < rn−1
rn−1 = rn qn
Euclidean Algorithm
Divide the greater number by smaller one.
Euclidean Algorithm
Divide the greater number by smaller one.
If the remainder is 0, GCD is the smaller number.
Euclidean Algorithm
Divide the greater number by smaller one.
If the remainder is 0, GCD is the smaller number.
Otherwise, divisor is divided by the remainder and this process
continues until obtaining 0 as the remainder.
Euclidean Algorithm
Divide the greater number by smaller one.
If the remainder is 0, GCD is the smaller number.
Otherwise, divisor is divided by the remainder and this process
continues until obtaining 0 as the remainder.
The previous remainder before 0 is GCD.
Euclidean Algorithm
Divide the greater number by smaller one.
If the remainder is 0, GCD is the smaller number.
Otherwise, divisor is divided by the remainder and this process
continues until obtaining 0 as the remainder.
The previous remainder before 0 is GCD.
Let us find the gcd(748,2024)
Euclidean Algorithm
Divide the greater number by smaller one.
If the remainder is 0, GCD is the smaller number.
Otherwise, divisor is divided by the remainder and this process
continues until obtaining 0 as the remainder.
The previous remainder before 0 is GCD.
Let us find the gcd(748,2024)
We will present two different methods that can be used to find a linear
combination of two integers equal to their greatest common divisor.
We will present two different methods that can be used to find a linear
combination of two integers equal to their greatest common divisor.
The first method proceeds by working backward through the divisions
of the Euclidean algorithm. We will illustrate how this method works
with an example.
We will present two different methods that can be used to find a linear
combination of two integers equal to their greatest common divisor.
The first method proceeds by working backward through the divisions
of the Euclidean algorithm. We will illustrate how this method works
with an example.
So this method requires a forward pass and a backward pass through
the steps of the Euclidean algorithm.
Lemma
If a, b, and c are positive integers s.t. gcd(a, b) = 1 and a | bc, then a | c.
Lemma
If a, b, and c are positive integers s.t. gcd(a, b) = 1 and a | bc, then a | c.
Lemma
If p is a prime and p | a1 a2 · · · an , where each ai ∈ Z, then p | ai for some i.
Lemma
If a, b, and c are positive integers s.t. gcd(a, b) = 1 and a | bc, then a | c.
Lemma
If p is a prime and p | a1 a2 · · · an , where each ai ∈ Z, then p | ai for some i.
Theorem
Let m be a positive integer and let a, b, and c be integers. If ac ≡ bc
(mod m) and gcd(c, m) = 1, then a ≡ b (mod m).
Lemma
If a, b, and c are positive integers s.t. gcd(a, b) = 1 and a | bc, then a | c.
Lemma
If p is a prime and p | a1 a2 · · · an , where each ai ∈ Z, then p | ai for some i.
Theorem
Let m be a positive integer and let a, b, and c be integers. If ac ≡ bc
(mod m) and gcd(c, m) = 1, then a ≡ b (mod m).
Theorem
If a and m are relatively prime integers and m > 1, then an inverse of a
modulo m exists. Furthermore, this inverse is unique modulo m.
Theorem
If a and m are relatively prime integers and m > 1, then an inverse of a
modulo m exists. Furthermore, this inverse is unique modulo m.
Theorem
If a and m are relatively prime integers and m > 1, then an inverse of a
modulo m exists. Furthermore, this inverse is unique modulo m.
Theorem
If a and m are relatively prime integers and m > 1, then an inverse of a
modulo m exists. Furthermore, this inverse is unique modulo m.
x ≡2 (mod 3),
x ≡3 (mod 5),
x ≡2 (mod 7)
Theorem
Let m1 , m2 , . . . , mn be pairwise relatively prime positive integers greater
than one and a1 , a2 , . . . , an arbitrary integers. Then the system
x ≡ a1 (mod m1 ),
x ≡ a2 (mod m2 ),
..
.
x ≡ an (mod mn )
Theorem
If p is prime and a is an integer not divisible by p, then
ap ≡ a (mod p).
Theorem
If p is prime and a is an integer not divisible by p, then
ap ≡ a (mod p).
We did not get the value 1, so it seems that Fermat’s little theorem is
not true for m. If m were prime, Fermat’s little theorem says that we
would obtained 1. Hence the number m = 15485207 is not prime.
We did not get the value 1, so it seems that Fermat’s little theorem is
not true for m. If m were prime, Fermat’s little theorem says that we
would obtained 1. Hence the number m = 15485207 is not prime.
It’s actually a bit astonishing. By a simple computation, we have
conclusively proven that m is not prime, yet we do not know any of
its factors!
Primality Testing
Is n = 31987937737479355332620068643713101490952335301 a
prime number?
Primality Testing
Is n = 31987937737479355332620068643713101490952335301 a
prime number?
n is not divisible by any primes smaller than 106 . So we begin to
suspect that maybe n is prime ??
Primality Testing
Is n = 31987937737479355332620068643713101490952335301 a
prime number?
n is not divisible by any primes smaller than 106 . So we begin to
suspect that maybe n is prime ??
Primality Testing
Is n = 31987937737479355332620068643713101490952335301 a
prime number?
n is not divisible by any primes smaller than 106 . So we begin to
suspect that maybe n is prime ??
ap−1 ≡ 1 (mod p)
Is n = 2967952985951692762820418740138329004315165131 prime?
2n ≡ 2 (mod n)
Is n = 2967952985951692762820418740138329004315165131 prime?
2n ≡ 2 (mod n)
Is n = 2967952985951692762820418740138329004315165131 prime?
2n ≡ 2 (mod n)
Is n = 2967952985951692762820418740138329004315165131 prime?
2n ≡ 2 (mod n)
Is n = 2967952985951692762820418740138329004315165131 prime?
2n ≡ 2 (mod n)
Carmichael Numbers
Definition
Fix an integer n. We say that an integer a is a witness for (compositeness
of) n if
an ̸≡ a (mod n)
Carmichael Numbers
Definition
Fix an integer n. We say that an integer a is a witness for (compositeness
of) n if
an ̸≡ a (mod n)
Carmichael Numbers
Definition
Fix an integer n. We say that an integer a is a witness for (compositeness
of) n if
an ̸≡ a (mod n)
Carmichael Numbers
Definition
Fix an integer n. We say that an integer a is a witness for (compositeness
of) n if
an ̸≡ a (mod n)
Carmichael Numbers
Definition
Fix an integer n. We say that an integer a is a witness for (compositeness
of) n if
an ̸≡ a (mod n)
Check Digits
Check Digits
Check Digits
Check Digits
x1 +3x2 +x3 +3x4 +x5 +3x6 +x7 +3x8 +x9 +3x10 +x11 +3x12 +x13 ≡0 (mod 10)
Check Digits
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11
where
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11
where
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11
where
TC ID Numbers Coding
7 8
9 0
7 8
9 0
I9×9
(x1 x2 x3 x4 x5 x6 x7 x8 x9 ) 7 8 = (x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 )
9 0
7 8
9 0
7 8
References