Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some z Z Notation: b Fact: for all, b, c Z:, 1, and 0 0 = 0 b and b c = c b and c = (b + c) b and b = ±b 1
Division with remainder property Let, b Z with b > 0 There exist unique q, r Z such that = bq + r and 0 r < b Proof: see class notes q = /b r = mod b 0 r b 2b 3b a 4b 2
Greatest Common Divisors For, b Z, we call d Z a common divisor of and b if d and d b d is called a greatest common divisor if d is non-negative, and all other common divisors of and b divide d Fact: greatest common divisors are unique: Suppose d and d are greatest common divisors of and b We must have d d and d d, so d = ±d Since d and d are non-negative, we must have d = d Notation: gcd(, b) But... we still need to prove that gcd(, b) always exists (according to our definition) We will give an algorithm that computes it 3
Algorithm E clid(, b): On input, b, where and b are integers such that b 0, compute gcd(, b) as follows: if b = 0 then return else return E clid(b, mod b) Correctness (induction on b): b = 0: gcd(, 0) = b > 0: write = bq + r d & d b d b & d r Example: = 100, b = 35 gcd(100, 35) = 5 0 1 2 3 100 35 30 5 b 35 30 5 0 4
Running Time: On input (, b) with b > 0: algorithm performs one division step then calls itself recursively on input (, b ), where := b and b := mod b so b > b It follows that # of division steps is at most b Better bound: O(log b) division steps Proof: if b > 0, the algorithm performs another division step, and calls itself again on input (, b ), where := b and b := b mod b, so that b > b q := b/b 1 b = b q + b b + b > 2b after two division steps, second argument to Euclid is < b/2 # of division steps 2 log 2 b 5
Bezout s Lemma Let, b Z and d := gcd(, b) (i) We have s + bt = d for some s, t Z (ii) For every d Z, we have d d s + bt = d Part (ii) follows easily from part (i): If d d, then dz = d, so set s := sz, t := tz for some s, t Z If s + bt = d, then since d and d b, it follows that d ( s + bt ) = d For part (i), we can modify the Euclidean Algorithm so that it computes s and t together with d 6
Algorithm ExtE clid(, b): On input, b, where and b are integers such that b 0, compute (d, s, t), where d = gcd(, b) and s and t are integers such that s + bt = d, as follows: if b = 0 then d, s 1, t 0 else q /b, r mod b (d, s, t ) ExtE clid(b, r) s t, t s qt return (d, s, t) Correctness (induction): = bq + r, bs + rt = d Substitute r := bq and re-arrange: t + b(s qt ) = d 7
Example: = 100, b = 35 0 1 2 3 100 35 30 5 b 35 30 5 0 s 1 1 0 1 t 3 1 1 0 q 2 1 6 s := t +1 and t := s +1 q t +1 d = 5, s = s 0 = 1, t = t 0 = 3 s + bt = 100 ( 1) + 35 (3) = 5 = d 8
Relatively prime numbers Let, b Z We say, b are relatively prime if gcd(, b) = 1 In other words, ±1 are the only common divisors of and b Special case of Bezout s Lemma: and b are relatively prime s + bt = 1 for some s, t Z Theorem 1: Let, b, c Z such that c divides b, and and c are relatively prime. Then c b Proof: Assume c b, gcd(, c) = 1. Want to show: c b gcd(, c) = 1 = s + ct = 1 for some s, t Z (Bezout) Multiply by b: bs + cbt = b c cbt, c bs, c b 9
Primes and composites Let n be a positive integer n is prime if n > 1 and the only positive integers that divide n are 1 and n n is composite if n > 1 and is not prime n is composite n = b for some integers, b with 1 < < n and 1 < b < n n = 1 is neither prime nor composite 10
Fundamental theorem of arithmetic: Every non-zero integer n can be expressed as n = ±p e 1 1 pe r r, where p 1,..., p r are distinct primes and e 1,..., e r are positive integers. Moreover, this expression is unique, up to a reordering of the primes 11
Proof (existence): Assume n positive Induction on n n = 1 n > 1. Induction hypothesis: every number smaller than n can be expressed as a product of primes If n is prime, then we re done Otherwise, n = b, where 1 < < n and 1 < b < n By induction, both and b can be expressed as a product of primes n can also be expressed as a product of primes Proof (uniqueness): that s the hard part... 12
Theorem 2: Let p be a prime. For all, b Z, if p b, then p or p b Proof: Suppose p b. Want to show: p or p b If p, we are done So assume p. Want to show p b As the only divisors of p are ±1 and ±p, the only common divisors of p and are ±1 So we have gcd(p, ) = 1 By Theorem 1 (with c := p), we have p b Generalization: if p is prime and p 1 k, then p for some = 1,..., k Proof: easy induction on k 13
Finishing proof of Fundamental Theorem (uniqueness) Suppose p 1 p r = q 1 q s, where the p s and q j s are primes ( ) Want to show that (p 1,..., p r ) is a re-ordering of (q 1,..., q s ) Induction on r: r = 0 r > 0: Since p 1 prime, we have p 1 q j for some j Since q j prime, we have p 1 = q j Cancel p 1 from LHS of ( ) and q j from RHS of ( ), and apply induction hypothesis 14