Chap04 Number Theory
Chap04 Number Theory
Chap04 Number Theory
Chapter 4
Number Theory
The Integers and Divison
Primes
Solution:
17 ≡ 5 (mod 6) because 6 divides 17 − 5 = 12.
24 ≢ 14 (mod 6) since 6 divides 24 − 14 = 10 is not
divisible by 6.
Primes
Primes
Definition: A positive 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.
Examples:
100 = 2 ∙ 2 ∙ 5 ∙ 5 = 22 ∙ 52
641 = 641
999 = 3 ∙ 3 ∙ 3 ∙ 37 = 33 ∙ 37
1024 = 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 = 210
Greatest Common Divisor
Greatest Common Divisor
Definition: Let a and b be integers, not both zero. The
largest integer d such that d | a and also 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).
Example: Determine whether the integers 10, 19, and 24 are pairwise
relatively prime.
Solution: Because gcd(10,24) = 2>1, so 10, 19, and 24 are not
pairwise relatively prime.
Finding the Greatest Common Divisor
Using Prime Factorizations
Suppose the prime factorizations of a and b are:
This formula is valid since the integer on the right (of the equals sign)
divides both a and b. No larger integer can divide both a and b.
Example: 120 = 23 .3 . 5 and 500 = 22 . 53
gcd(120,500) = 2min(3,2) 3min(1,0) 5min(1,3) = 22 30 51 = 20
Finding the gcd of two positive integers using their prime factorizations
is not efficient because there is no efficient algorithm for finding the
prime factorization of a positive integer.
Applications of Number Theory
Euclidean Algorithm
Euclid
(325 B.C.E. – 265 B.C.E.)
The Euclidian algorithm is an efficient method for
computing the greatest common divisor of two integers. It
is based on the idea that gcd(a,b) is equal to gcd(a,c) when
a > b and c is the remainder when a is divided by b.
Example: Find gcd(91, 287):
287 = 91 ∙ 3 + 14 Divide 287 by 91
91 = 14 ∙ 6 + 7 Divide 91 by 14
14 = 7 ∙ 2 + 0 Divide 14 by 7
Stopping
condition
continued →
Correctness of Euclidean Algorithm
Lemma 1: Let a = bq + r, where a, b, q, and r are integers.
Then gcd(a,b) = gcd(b,r).
Proof:
Suppose that d divides both a and b. Then d also divides a − bq = r
(by Theorem 1 of Section 4.1). Hence, any common divisor of a and
b must also be any common divisor of b and r.
Suppose that d divides both b and r. Then d also divides bq + r = a.
Hence, any common divisor of a and b must also be a common
divisor of b and r.
Therefore, gcd(a,b) = gcd(b,r).
gcds as Linear Combinations
Étienne Bézout
(1730-1783)
Bézout’s Theorem: If a and b are positive integers, then there exist
integers s and t such that gcd(a,b) = sa + tb.
Definition: If a and b are positive integers, then integers s and t such that
gcd(a,b) = sa + tb are called Bézout coefficients of a and b. The equation
gcd(a,b) = sa + tb is called Bézout’s identity.