Title: The Fundamental Theorem of Arithmetic
1The Fundamental Theorem of Arithmetic
2Primes
- p gt 1 is prime if the only positive factors are
1 and p - if p is not prime it is composite
The Fundamental Theorem of Arithmetic
Every positive integer can be expressed as a
unique product of primes
My name is Euclid
3Primes
There is no other factoring!
4325BC to 265BC
Euclid of Alexandria
5Primes
Euclids words if a number be the least that is
measured by prime numbers, it will not be
measured by any other prime except those
originally measuring it Where measuring is
dividing
The Elements
6(No Transcript)
7Proof of Fundamental Theorem of Arithmetic
- Well Ordering Principle (WOP)
- every non-empty set of positive integers has a
least element
RTP Every integer n gt 1 can be written as a
product of primes
- If n is prime we are done
- n is composite and has a positive divisor 1 lt p
lt n - let p1 be the smallest of these divisors
- p1 must be prime otherwise
- there is an integer k, 1 lt k lt p1, and k divides
p1 - consequently n n1 times p1 (i.e. n1 n ?
p1) - where p1 is prime and n1 lt n
- repeat the argument with n1
- If n1 is prime we are done
- otherwise n1 n2 times p2
- where p2 is prime and n2 lt n1 and p2 ? p1
- this process terminates due to the WOP
8PRIMES
- The dumb way to test if n is prime
- if n is divisible by 2 return(composite)
- if n is divisible by 3 return(composite)
- if n is divisible by 4 return(composite)
-
- if n is divisible by n-1 return(composite)
- return(prime)
Question is n (n gt 2) ever divisible by n-1?
9PRIMES
Therefore, the divisor a or b is either prime or
due to the fundamental theorem of arithmetic, can
be expressed as a product of primes
(p 211 6th ed, p 155 5th ed)
10PRIMES
We now have a test for primality If a number is
not composite it is prime If a number is prime
then it does NOT have a prime divisor less than
or equal to ?n Therefore we can test if n is
divisible by primes in the range 2 to ?n If
none are found n must be prime
11Primes
Prove that 41 is prime
To be prime, 41 must not be composite
If composite 41 has a divisor less than or equal
to square root of 41
The only primes not exceeding 6 are 2, 3, and
5 None of these divides 41 Therefore 41 is not
composite, it is prime
Remember floor(x) ?x? the largest integer
smaller than x
12Primes for the class!
Prove that 67 is prime
To be prime, 67 must not be composite
If composite 67 has a divisor less than or equal
to square root of 67
The only primes not exceeding 8 are 2, 3, 5, and
7 None of these divides 67 Therefore 67 is not
composite, it is prime
13Is 51 prime?
Consider prime divisors 2, 3, 5, 7 only
?
14Primes
Compute the prime factorisation of n
The Fundamental Theorem of Arithmetic
Revisited
Every positive integer can be expressed as a
unique product of primes
15Primes
Compute the prime factorisation of n
- assume nextPrime(i) delivers next prime number
greater than i - nextPrime(7) 11 and nextPrime(nextPrime(7))
13 - floor(sqrt(n)) delivers largest integer ? square
root of n - floor(sqrt(97)) 9
p 2 // the 1st prime rootN floor(sqrt(N))
// where we stop while p lt rootN do begin
if pn then begin print(p) //
p is a prime divisor n n/p
rootN floor(sqrt(n)) end
else p nextPrime(p) end print(p)
16Primes
p 2 // the 1st prime rootN floor(sqrt(N))
// where we stop while p lt rootN do begin
if pn then begin print(p) //
p is a prime divisor n n/p
rootN floor(sqrt(n)) end
else p nextPrime(p) end print(p)
N p rootN
7007 2 83
7007 3 83 7007
5 83 7007 7
83 print 7 1001 7
31 print 7 143 7
11 143 11 11 print
11 13 11
3 print 13
7007 7.7.11.13
17Greatest common divisor gcd(a,b) and Least common
multiple
- gcd(a,b) is largest d such that da and db
- if gcd(a,b) 1 then a and b are relative prime
- lcm(a,b) is the smallest/least x such that ax
and bx
- 3 Naïve algorithms for gcd(a,b)
- start with x at 1 up to min(a,b) testing if x
a and x b - remember the last (largest) successful value
- start with x at min(a,b) and count down to 1
testing if xa and xb - stop when the first value of x is found
- compute the prime factorisation of a and of b
- and then see below
18Greatest common divisor gcd(a,b)
- gcd(120,500)
- prime factorisation of 120 is 2.2.2.3.5
- prime factorisation of 500 is 2.2.5.5.5
20
but there is a better algorithm (wots an
algorithm?)
19(No Transcript)
20Lowest/least common multiple lcm(a,b) smallest
x divisible by a and by b
- lcm(95256,432)
- prime factorisation of 95256 is
2.2.2.3.3.3.3.3.7.7 - prime factorisation of 432 is 2.2.2.2.3.3.3
190512