Number Theory
Lecture 6
1 / 23
Lecture Structure
1. Divisibility and Modular Arithmetic
2. Integer Representations and Algorithms
3. Primes and Greatest Common Divisors
2 / 23
Definition
Let b ∈ Z and a ∈ Z with a ̸= 0.
Definition
• We say that a divides b if there is an integer c such that b = ac, or equivalently, if ba
is an integer.
• 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.
3 / 23
Example
• 2 divides 18 (2|18)
• 18 does not divide 2 (18 ∤ 2)
• 9 is divisible by 3 (3|9)
• 9 is not divisible by 2 (2 ∤ 9)
• 3 is a divisor of 9 (3|9)
• 2 is not a divisor of 9 (2 ∤ 9)
• 9 is a multiple of 3 (3|9)
4 / 23
Theorems
Let a, b, c ∈ Z and a ̸= 0.
Theorem
• (a|b ∧ a|c) → a|(b + c)
• a|b → a|bc
• (a|b ∧ b|c) → a|c
5 / 23
The Division Algorithm
Theorem
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 .
a — dividend
d — divisor
r — remainder
q — quotient
r = a mod d
q = a div d
6 / 23
Example
• 50 div 8 = 6
• 50 mod 8 = 2
• 50 div 10 = 5
• 50 mod 10 = 0
• −50 div 8 = −7
• −50 mod 8 = 6
• 8 div 50 = 0
• 8 mod 50 = 8
Find 50 div − 8
Find 50 mod − 8
7 / 23
Modular Arithmetic
Let a, b ∈ Z and m ∈ N.
Definition
a is said to be congruent to b modulo m if m divides a − b.
• a ≡ b(modm) is called a congruence and m is its modulus (plural moduli).
• If a and b are not congruent modulo m, we write
a ̸≡ b(modm).
8 / 23
Example
• 20 ≡ 43(mod23)
• 17 ≡ 22(mod5)
• 63 ≡ 53(mod10)
• 25 ̸≡ 17(mod5)
• 18 ̸≡ 12(mod4)
9 / 23
Theorems
Let a, b ∈ Z and m ∈ N.
Theorem
a ≡ b(modm)
if and only if
a mod m = b mod m
Theorem
a ≡ b(modm)
if and only if there exists an integer k such that
a = b + km
10 / 23
Theorems
Let a, b, c, d ∈ Z and m ∈ N.
Theorem
If
a ≡ b(modm) and c ≡ d(modm)
then
• a + c ≡ b + d mod m
• a · c ≡ b · d mod m
11 / 23
Representations of Integers
Let b ∈ N and b > 1.
Theorem
Any positive integer n, can be expressed uniquely in the form
n = ak b k + ak−1 b k−1 + . . . + a1 b + a0 ,
where k is a nonnegative integer,
a0 , a1 , . . . , ak
are nonnegative integers less than b, and ak ̸= 0.
Definition
This representation is called the base b expansion of n and denoted by
(ak ak−1 ak−2 . . . a1 a0 )b
12 / 23
Example
• The base 7 expansion of 244 is (466)7 , indeed
244 = 4 · 72 + 6 · 71 + 6 = (466)7
• 244 = (244)10 is a decimal expansion.
244 = 2 · 102 + 4 · 101 + 4
13 / 23
How many digits?
If
b d−1 ≤ n < b d
then the base b expansion of n has d digits.
b d−1 ≤ n < b d
d − 1 ≤ logb n < d
d − 1 = [logb n]
d = [logb n] + 1
14 / 23
Modular Exponentiation
In cryptography it is important to be able to find
b n mod m
efficiently, where b, n and m are large integers.
It is impractical to first compute b n and then find its remainder when divided by m
because b n will be a huge number.
Instead, we can use an algorithm that employs the binary expansion of the exponent n.
15 / 23
Modular Exponentiation Algorithm
16 / 23
Definition
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.
Note
The integer n is composite if and only if there exists an integer a such that a|n and
1 < a < n.
17 / 23
Theorems
Theorems
• Every integer greater than 1 can be written uniquely as a prime or as the product of
two or more primes where the prime factors are written in order of nondecreasing size.
√
• If n is a composite integer, then n has a prime divisor less than or equal to n.
• There are infinitely many primes.
1. Find the prime factorization of 7007.
2. Show that 101 is prime.
18 / 23
The Sieve of Eratosthenes
The sieve of Eratosthenes is used to find all primes not exceeding a specified positive
integer. For instance, the following procedure is used to find the primes not exceeding
100.
• We begin with the list of all integers between 1 and 100. To
begin the sieving process, the integers that are divisible by 2,
other than 2, are deleted.
• Because 3 is the first integer greater than 2 that is left, all
those integers divisible by 3, other than 3, are deleted.
• Because 5 is the next integer left after 3, those integers
divisible by 5, other than 5, are deleted.
• The next integer left is 7, so those integers divisible by 7,
other than 7, are deleted.
• Because all composite integers not exceeding 100 are divisible
by 2, 3, 5, or 7, all remaining integers except 1 are prime.
19 / 23
The Euclidean Algorithm
Theorem
Let
a = bq + r ,
where a, b, q, and r are integers. Then
gcd(a, b) = gcd(b, r ).
Find the greatest common divisor of 414 and 662 using the Euclidean algorithm.
20 / 23
gcds as Linear Combinations
An important result we will use is that gcd(a, b) can be expressed in the form
sa + tb,
where s and t are integers.
In other words, gcd(a, b) can be expressed as a linear combination with integer
coefficients of a and b.
For example, gcd(6, 14) = 2, and 2 = −2 · 6 + 1 · 14.
Bezout’s Theorem
If a and b are positive integers, then there exist integers s and t such that
gcd(a, b) = sa + tb.
21 / 23
Example
Represent gcd(414, 662) as a linear combination of 414 and 662.
22 / 23
Optional Project Work
1. Write a program that finds base b-expansion of n.
2. Write a program that finds gcd(a, b) using The Euclidean Algorithm.
3. Prove any theorem on page 18
4. Mersenne primes.
5. Goldbach’s Conjecture.
• All tasks - 1 point
• No teams
• Use any source
23 / 23