Transcript ch03s7
Sets, Combinatorics, Probability, and
Number Theory
Mathematical Structures
for Computer Science
Chapter 3
Copyright © 2006 W.H. Freeman & Co.
MSCS Slides
Probability
Fundamental Theorem of Arithmetic
FUNDAMENTAL THEOREM OF ARITHMETIC
For every integer n 2, n is a prime number or can be
written uniquely (ignoring ordering) as a product of
prime numbers.
We ignore the order in which we write the factors:
2(3)(3) = 3(2)(3)
If a and b are positive integers, then gcd(a,b) can
always be written as a linear combination of a and b,
that is, gcd(a,b) = ia + jb for some integers i and j.
Section 3.7
gcd(420,66) = 6 = 3(420) 19(66)
Number Theory
1
Fundamental Theorem of Arithmetic
The values 3 and 19 in gcd(420,66) = 3(420) 19(66)
are derived from the successive divisions done by the
Euclidean algorithm:
420 = 6 * 66 + 24
66 = 2 * 24 + 18
24 = 1 * 18 + 6
18 = 3 * 6 + 0
Rewriting the first three equations from the bottom up:
6 = 24 * 1 + 18
18 = 66 * 2 + 24
24 = 420 * 6 + 66
Now we use these equations in a series of substitutions:
6 = 24 1 * 18 = 24 1 * (66 2 * 24) (substituting for 18)
= 3 * 24 66
= 3 * (420 6 * 66) 66 (substituting for 24)
= 3 * 420 19 * 66
Section 3.7
Number Theory
2
Fundamental Theorem of Arithmetic
THEOREM ON gcd(a, b)
Given positive integers a and b, gcd(a,b) is the linear
combination of a and b that has the smallest positive
value.
From the theorem on gcd(a,b), it follows that a and b
are relatively prime if and only if there exist integers i
and j such that:
ia + jb = 1
DEFINITION: RELATIVELY PRIME
Two integers a and b are relatively prime if gcd(a,b)
1.
Section 3.7
Number Theory
3
Fundamental Theorem of Arithmetic
THEOREM ON DIVISION BY PRIME
NUMBERS
Let p be a prime number such that p ab, where a and
b are integers. Then, either p a or p b.
To find the unique factorization of 825 as a product of
primes, we can start by simply dividing 825 by
successively larger primes:
825 = 3 * 275 = 3 * 5 * 55 = 3 * 5 * 5 * 11 = 3 * 52 * 11
Doing the same on 455:
455 = 5 * 7 * 13
Section 3.7
From these factorizations, we can see that gcd(825,
455) = 5.
Number Theory
4
More on Prime Numbers
Section 3.7
THEOREM ON SIZE OF PRIME FACTORS
If n is a composite number, then it has a prime factor
less than or equal to (n)1/2.
Given n = 1021, let’s find the prime factors of n or
determine that n is prime. The value of (1021)1/2 is just
less than 32. So the primes we need to test are 2, 3, 5,
7, 11, 13, 17, 19, 23, 29, 31. None divides 1021, so
1021 is prime.
Number Theory
5
More on Prime Numbers
Section 3.7
THEOREM ON INFINITY OF PRIMES
(EUCLID)
There is an infinite number of prime numbers.
Assume that there is a finite number of primes. Let the
value of s = the sum of all primes + 1. Therefore, s is
not prime. Thus, s is composite and by the
fundamental theorem of arithmetic, s can be factored
as a product of (some of) the prime numbers.
Suppose that pj is one of the prime factors of s, that is,
s = pj (m) for some integer m. Then:
1 = s – p1 p2 … pk = pj(m) p1 p2 … pk
= pj (m p1 … pj 1 pj + 1 …pk)
Therefore, pj 1, which is a contradiction.
Number Theory
6
Euler Phi Function
DEFINITION: EULER PHI FUNCTION
For n an integer, n 2, the Euler (pronounced
“oiler”) phi function of n, (n), is the number of
positive integers less than or equal to n and relatively
prime to n. ((n) is pronounced “fee” of n.)
For example:
Section 3.7
(2) = 1 (the number 1)
(3) = 2 (the numbers 1, 2)
(4) = 2 (the numbers 1, 3)
(5) = 4 (the numbers 1, 2, 3, 4)
(6) = 2 (the numbers 1, 5)
(7) = 6 (the numbers 1, 2, 3, 4, 5, 6)
Number Theory
7