COMP 2711H: Lecture 22
Date: 2024-10-21 18:01:38
Reviewed:
Topic / Chapter:
summary
❓Questions
Notes
Euclidean Algorithm
- 
Euclidean algorithm- theorem: if , , 
- then
 
- proof
- 
- as
 
- 
- as
 
 
- 
- algorithm
Pseudocode gcd(a,b): if b|a: return b let q,r be s.t. a = q\cdot b + r return gcd(b,r)
- C++ way
int gcd(int a, int b) { if (a % b == 0) return b return gcd(b, b % a) }
- algorithm: terminates as value of keep decreases
- from 3711H: Euclidean algorithm has  runtime
- 👨🏫 quick!
 
- Euclidean algorithm: explains how to write as linear combination of
- example: 
- or, the other way:
 
 
- theorem: if , , 
- 
LCM: least common multiple- two definitions possible
- :  s.t.
- 
- or
 
 
- theorem: for 
- proof (without prime factorization)
- 
- show: satisfies properties of
 
- using 
-  where 
- thus : common multiple of
 
- suppose:  a common multiple of 
- given , then
- and : integers
- thus
- and
 
 
 
- 
- corollary: if : then 
- trivial: as
 
 
Prime Number and Fundamental Theorem of Arithmetic
- 
Prime numbers- an integer : prime if its only divisors are 
- notice that: only positive integer excluding is eligible for prime
 
- theorem: if : prime and  then
- if : divisor of => theorem holds
- what if: ? we must show 
- , as it would mean
- thus, must be 1, as and
- by Euclid's lemma:
 
- corollary: if : then
- corollary: if , where  are all prime:
- then
 
 
- an integer : prime if its only divisors are 
- 
Fundamental theorem of arithmetic- for every integer , we can write:
-  where every : a prime, and 
- not necessarily distinct (e.g. )
 
- we call this: prime factorization of 
- and this is unique for each number
 
 
-  where every : a prime, and 
- proof of existence: strong induction on 
- base case:
- consider: prime factorization
- case 1: if prime:
- case 2: if  composite: 
- let
- , thus prime factorization for  exists
- let
- and
- then (sorted)
 
 
 
- proof of uniqueness:
- suppose
- then 
- e.g. : can divide all sides
 
- from corollary, 
- eliminate from both sids
 
- that way, you can continue to eliminate all  prime factors.
- 👨🎓 in the end: they must be equal, and you realize that both sides were same from the first place
 
 
 
- for every integer , we can write:
- 
More compact notation- example:
- let
- let
- then:
- then:
- this theorem: makes proof of many previous theorem easy
- e.g.
 
- theorem:  is irrational
- let and , then
- 
- as ,
- thus : thus contradiction
 
 
- theorem: there are infinitely many primes
- suppose: : all possible primes
- then 
- f
 
- theorem: suppose : -th prime number
- 👨🏫 prove it using induction, and show it holds for all previous primes
- as we know upper-bound of next prime