01/29/13 Number Theory: Factors and Primes Discrete Structures (CS 173) Derek Hoiem, University of Illinois http://www.brooksdesign- ps.net/Reginald_Brooks/ Code/Html/pin2.htm 1
01/29/13
Number Theory: Factors and Primes
Discrete Structures (CS 173)
Derek Hoiem, University of Illinois
http://www.brooksdesign-
ps.net/Reginald_Brooks/
Code/Html/pin2.htm
1
Goals of this lecture
โข Understand basic concepts of number theory including divisibility, primes, and factors
โข Be able to compute greatest common divisors and least common multiples
2
Number theory: the study of integers (primes, divisibility, factors, congruence, etc.)
3
Leonard Dickson
(1874-1954)
Thank God that number theory is unsullied by any
application
Virtually every theorem in elementary number theory arises in a natural, motivated way in connection with the problem of making computers do high-speed numerical calculations
Donald Knuth
(quote from 1974)
Other applications include cryptography (e.g., RSA encryption)
http://en.wikipedia.org/wiki/RSA_(algorithm)
Divisibility
4
Suppose ๐ and ๐ are integers.
Then ๐ divides ๐ iff ๐ = ๐๐ for some integer ๐.
โ๐ divides ๐โ โก โ๐ | ๐โ
๐ is a factor or
divisor of ๐
๐ is a multiple of a
Tip: think โa divides into bโ
Example: 5 | 55 because 55 = 5 โ 11
Examples of divisibility
โข Which of these holds?
4 | 12 11 | -11
4 | 4 -22 | 11
4 | 6 7 | -15
12 | 4 4 | -16
6 | 0
0 | 6 5
(๐ | ๐) โ (๐ = ๐๐), where ๐ is some integer
Proof with divisibility
Claim: For any integers ๐, ๐, ๐, if ๐|๐ and b|๐, then ๐|๐.
Definition: integer ๐ divides integer ๐ iff ๐ = ๐๐ for some integer ๐
overhead 6
Proof with divisibility
Claim: For any integers ๐, ๐ฅ, ๐ฆ, ๐, ๐, if ๐|๐ฅ and ๐|๐ฆ, then ๐|๐๐ฅ + ๐๐ฆ.
Definition: integer ๐ divides integer ๐ iff ๐ = ๐๐ for some integer ๐
overhead 7
Prime numbers
โข Definition: an integer ๐ โฅ 2 is prime if the only positive factors of ๐ are 1 and ๐.
โข Definition: an integer ๐ โฅ 2 is composite if it is not prime.
โข Fundamental Theorem of Arithmetic: Every integer โฅ 2 can be written as the product of one or more prime factors. Except for the order in which you write the factors, this prime factorization is unique.
8
600=2*3*4*5*5
More factor definitions
โข Greatest common divisor (GCD): gcd (๐, ๐) is the largest number that divides both ๐ and ๐ โ Product of shared factors of ๐ and ๐
โข Least common multiplier (LCM): lcm ๐, ๐ is the smallest number that both ๐ and ๐ divide
โข Relatively prime: ๐ and ๐ are relatively prime if they share no common factors, so that gcd ๐, ๐ = 1
9
Factor examples
gcd(5, 15) =
gcd(0, k) =
gcd(8, 12) =
gcd(8*m, 12*m) =
gcd(k^3, m*k^2) =
10
lcm(120, 15) =
lcm (6, 8) =
lcm(0, k) =
Which of these are relatively prime?
6 and 8?
5 and 21?
6 and 33?
3 and 33?
Any two prime numbers?
Euclidean algorithm for computing gcd
12
x y ๐=remainder ๐ฅ, ๐ฆ
remainder ๐, ๐ is the remainder when ๐ is divided by ๐
gcd (969,102)
Euclidean algorithm for computing gcd
13
x y ๐=remainder ๐ฅ, ๐ฆ
remainder ๐, ๐ is the remainder when ๐ is divided by ๐
gcd (3289,1111)
But why does Euclidean algorithm work?
15
Euclidean algorithm works iff gcd ๐, ๐ = gcd ๐, ๐ ,
where ๐ = remainder(๐, ๐)
Proof of Euclidean algorithm
16
Claim: For any integers ๐, ๐, ๐, ๐, with ๐ > 0, if ๐ = ๐๐ + ๐ then gcd ๐, ๐ =gcd (๐, ๐).
overhead