MATH 501 Discrete Mathematics Lecture 6: Number theory Prof. Dr. Slim Abdennadher, slim.abdennadher@guc.edu.eg German University Cairo, Department of Media Engineering and Technology 1 Number theory Number theory 1.1 Examples Some examples Number theory revolves around integers. Some simple examples: Can the sum of two squares be a square? Are 8 and 9 the only consecutive powers? Ask for the solution to X a y b = 1 in integers Every natural number is the sum of four integer squares 1.2 Divisibility Some operations Number theory revolves around integers. Some simple operations: A number m divides n if m > 0 and there is a k such that mk = n m\n m > 0 and k. n = mk The remainder of a division is given through the modulo operation: remainder n {}}{ n = m + n mod m }{{ m } quotient 1
LCM and GCD Comparing multiples and divisors of two numbers The least common multiple lcm(n, m) of two numbers n and m is defined as lcm(n, m) = min{k k > 0, n\k and m\k} Rational number arithmetic (finding the least common denominator) Real-time systems (finding the period of a set of rates) The greatest common divisor gcd(n, m) of two numbers n and m is defined as gcd(n, m) = max{k k\n and k\m} Finding the lowest terms of a rational number Cryptography Greatest common divisor The gcd is usually found using the Euclidean algorithm: gcd(n, n) = n This can be rephrased as Greatest common divisor Note that gcd(n, m) = gcd(max(n, m) min(n, m), min(n, m)) gcd(0, m) = m gcd(n, m) = gcd(m mod n, n) k\n and k\m k\ gcd(n, m) Also: n, m Z. n, m Z. n n + m m = gcd(n, m) Greatest common divisor: A property Consider and We claim: x Z Def. = {xz z Z} x Z + y Z Def. = {xu + yz u, z Z} a Z + b Z = d Z d = gcd(a, b). 2
Greatest common divisor: A property Proof: a Z + b Z = gcd(a, b) Z. Showing a Z + b Z gcd(a, b) Z Let k a Z + b Z. Then k = ax + by for some x, y Z. Since gcd(a, b)\ax and gcd(a, b)\by we have the gcd(a, b)\k. Thus k gcd(a, b) Z. Showing a Z+b Z gcd(a, b) Z Let k gcd(a, b) Z. Then k = gcd(a, b) n for some n. We know that there exists an a and a b such that a a + b b = gcd(a, b). Thus k = n gcd(a, b) = na a + nb b a Z + b Z. Least Common Multiple The lcm could be found using the gcd: 1.3 Primes Definition lcm(n, m) = n m gcd(n, m) Definition 1 (Prime). A positive integer p is called prime if it has just two divisors: 1 and p. by convention 1 is not prime. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,... A number which is not prime (precisely: which has nontrivial divisors) is called composite Any number n > 1 is either prime or composite. Prime factorization Primes form the scaffold of all positive integers Every positive integer n can be written as a product n = p 1 p m = of prime numbers p 1,..., p m. Show by course-of-value induction. 1 k m This prime factorization is unique (short of permutations): For every positive integer n there is exactly one prime factorization. Show by course-of-value induction. In the induction step assume that more than one factorization exists and derive a contradiction. p k 3
Prime factorization Moreover, every positive integer n can be uniquely written in the form n = p np p prime where n p 0 is the count of each prime p in the unique prime factorization of n. 60 = 2 2 3 5 = 2 2 3 1 5 1 7 0 11 0 13 0 = p np, with n p = 2, 1, 1, 0, 0, 0,... p prime Prime factorization We can think of the sequence n 2, n 3, n 5,... as a number system for positive integers, as each uniquely represents a number. To multiply numbers in this system...... simply add their representations. Example 2. 26: 1, 0, 0, 0, 0, 1, 0,... 28: 2, 0, 0, 1, 0, 0, 0,... 26 28: 3, 0, 0, 1, 0, 1, 0,... represents 728 Prime factorization The uniqueness of the prime factorization is called the... Theorem 3 (Fundamental Theorem of Arithmetic). Every positive integer n can be uniquely decomposed into prime factors. How many prime numbers are there? Let s assume there are only k primes for some k > 0 Then we can find a number M = 2 3 5... p k + 1 However, there is no prime p i {2, 3,..., p k } such that p i \M (because each of them divides M 1). Thus, either M is prime or there are primes p x1,..., p xm factorize M. Contradiction! {2, 3,..., p k } that So there are infinitely many primes. 4
GCD is MIN of Exponents of Prime Factors STEP 1: Find the prime factorization of each integer. 375 = 3 5 3 525 = 3 5 2 7 STEP 2: List the common prime divisors (factors) with the least power of all the given integers. 375 = 3 5 3 = 3 5 2 5 525 = 3 5 2 7 = 3 5 2 7 Common Prime Divisors (Factors) with Least Power: 3 and 5 2 STEP 3: Multiply the common prime divisors (factors) to find the GCD 3 5 2 = 75 GCD is MIN of Exponents of Prime Factors STEP 3: Multiply the common prime divisors (factors) to find the GCD 3 5 2 = 75 LCM is MAX of Exponents of Prime Factors STEP 1: Find the prime factorization of each integer. 4 = 2 2 10 = 2 5 45 = 3 2 5 STEP 2: List the prime divisors (factors) with the greatest power of all the given integers. 4 = 2 2 10 = 2 5 45 = 3 2 5 Prime Divisors (Factors) with Greatest Power: 2 2, 3 2, and 5 LCM is MAX of Exponents of Prime Factors STEP 3: Multiply the prime divisors to find the lcm 2 2 3 2 5 = 180 5
Relative primality We call n and m relative prime iff gcd(n, m) = 1. n m Def. gcd(n, m) = 1 Note: Likewise: n gcd(n, m) m gcd(n, m) k n and k m k nm 2 Modulo arithemtics 2.1 Modulo congruence The congruence relation We define: a b (mod m) Def. a mod m = b mod m Example 4. Since 9 16 (mod 5) 9 mod 5 = 4 = ( 16) mod 5. Arithmetics with congruences Some examples for calculating with congruences: Let a b (mod m) and c d (mod m). Then a + c b + d (mod m) a c b d (mod m) a c b d (mod m) Also And a b a n b n (mod m) d m (ad bd a b (mod m)) 6