Integers&Divisions
Integers&Divisions
3 Solving Congruences
4 Cryptography
Examples:
• 4 | 24 True or False ? True
• 4 is a factor of 24
• 24 is a multiple of 4
• 3 | 7 True or False ? False
Division
Relations:
• q = a div d , r = a mod d
Division
Definition
If a and b are integers with a = 0, then a divides b if there exists an
integer c such that b = ac.
Let
1 If a|b
a, b, cand
be integers, a|(b +ac).
a|c, thenwhere = 0.
2 If a|b, then a|bc for all integers c.
3 If a|b and b|c, then a|c.
Theorem
If a is an integer and d a positive integer, then there are unique
integers q and r , with 0 ≤ r < d, such that a = dq + r
Definition
If a and b are integers and m is a positive integer, then a is congruent
to b modulo m iff m|(a − b).
7 / 35
Congruence: Examples
Example: Determine
Whether 17 is congruent to 5 modulo 6, and
Whether 24 and 14 are congruent modulo 6.
Clicker
1 No and No.
2 No and Yes.
3 Yes and No.
4 Yes and Yes.
Example: Determine
Whether 17 is congruent to 5 modulo 6, and
Whether 24 and 14 are congruent modulo 6.
Clicker
1 No and No.
2 No and Yes.
3 Yes and No.
4 Yes and Yes.
Solution: 17 ≡ 5( mod 6) because 6 divides 17 − 5 =
12.
Example: Determine
Whether 17 is congruent to 5 modulo 6, and
Whether 24 and 14 are congruent modulo 6.
Clicker
1 No and No.
2 No and Yes.
3 Yes and No.
4 Yes and Yes.
Solution: 17 ≡ 5( mod 6) because 6 divides 17 − 5 = 12.
24 ≡ 14( mod 6) since 24 − 14 = 10 is not divisible by 6.
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.
Proof.
If a ≡ b( mod m), then (by the definition of congruence)
m|(a − b). Hence, there is an integer k such that a − b = km
and equivalently a = b + km.
Conversely, if there is an integer k such that a = b + km, then
km = a − b. Hence, m|(a − b) and a ≡ b( mod m).
Proof.
Since a ≡ b( mod m) and c ≡ d ( mod m), by the Theorem above
there are integers s and t with b = a + sm and d = c + tm.
Therefore,
b + d = (a + sm) + (c + tm) = (a + c) + m(s + t ), and
bd = (a + sm)(c + tm) = ac + m(at + cs + stm).
Hence, a + c ≡ b + d ( mod m) and ac ≡ bd ( mod m).
Corollary
Let m be a positive integer and let a and b be integers. Then
(a + b) mod m = ((a mod m) + (b mod m)) mod m
ab mod m = ((a mod m)(b mod m)) mod m.
Discrete Mathematics. Chapter 4 9 / 35
Arithmetic modulo m
Theorem
Let b be a positive integer greater than 1. Every positive integer n can
be expressed uniquely in the form:
If i >
4 √
n then stop else goto step 2.
Examples:
• gcd(24,36) = ?
• 24 = 2*2*2*3=23*3
• 36= 2*2*3*3=22*32
• gcd(24,36) =22*3 = 12
Greatest Common Divisor
Definition
Let a, b ∈ Z − {0}. The largest integer d such that d|a and also d|b
is called the greatest common divisor of a and b. It is denoted by
gcd (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.
It is denoted by lcm(a, b).
gcd (a, b) = 1 1 1 p 2 2 2 . . . n n n
min(a ,b ) min(a ,b ) min(a ,b )
p p
This number clearly divides a and b. No larger number can divide both
a and b. Proof by contradiction and the prime factorization of a
postulated larger divisor.
. . .n
max(a ,b ) max(a ,b ) max(a ,b )
lcm(a, b) = 1 1 1
p2 2 2 nn
p p
This number is clearly a multiple of a and b. No smaller number can be
a multiple of both a and b. Proof by contradiction and the prime
factorization of a postulated smaller multiple.
Proof.
Suppose that d divides both a and b. Then d also divides a − bq = r .
Hence, any common divisor of a and b must also be a common divisor
of b and r .
For the opposite direction suppose that d divides both b and r . Then d
also divides bq + r = a. Hence, any common divisor of b and r must
also be a common divisor of a and b.
Therefore, gcd (a, b) = gcd (b, r ).
This means that if a > b then gcd (a, b) = gcd (b, a mod b),
which directly yields the algorithm.
(Note that both arguments have gotten smaller.) One can show that its
complexity is O(log b).
Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 4 19 / 35
Gcd as a Linear Combination
Definition
A congruence of the form
ax ≡ b( mod m)
The solution of the congruence are all the integers x that satisfy
it.
Definition
1 · 5 ≡ 5(
mod 15)
2 · 5 ≡ 10(
mod 15)
3 · 5 ≡ 0(
mod 15)
4 · 5 ≡ 5(
mod 15)
5 · 5 ≡ 10(
mod 15)
6 · 5 ≡ 0(
mod 15)
7 · 5 ≡ 5(
Richard Mayr (University of Edinburgh, UK)
mod 15)
Discrete Mathematics. Chapter 4 24 / 35
The multiplicative group
ZTheorem
m
∗
mod p
Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 4 28 / 35
Fermat’s Little Theorem
c ≡ me mod n
m ≡ cd mod n
mod p)
med = mh(p−1)(q−1)m = (mp−1)h(q−1)m ≡ 1h(q−1)m ≡ m(