Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Course notes on Number Theory In Number Theory, we make the decision to work entirely with whole numbers. There are many reasons for this besides just mathematical interest, not the least of which is that computers can only work with whole numbers precisely—everything else is just an approximation. So, if all that we are allowed to work with are whole numbers, what can we do? Can we add two whole numbers? Yes, because we always get back another whole number. Can we multiply? Yes. Can we divide? No. More often than not, when we divide two whole numbers what we get is a fraction. Therefore, in Number Theory, we’ll have to treat division differently. The thing to remember throughout this discussion is that we are trying to figure out how to replace the division operation with the division algorithm. 1 Integer Division What dividing a by b really tells you is how many times you can ’fit’ b into 1 1 a. For example, 2 goes into 3 1 times. (i.e. 3 ÷ 2 = 1 ) In general, when 2 2 we want to know how many times b goes into a, we can always write a in terms of b like so: a = qb + r, where 0 ≤ r < b This is known as the division algorithm and it tells us that b goes into a q times with r left over. So, to be formal: Theorem 1 (The Division Algorithm) If a, b ∈ Z, with b > 0 then there exist unique q, r ∈ Z with a = qb + r, 0 ≤ r < b . The number q is called the quotient and r is called the remainder. The division algorithm replaces the division operation in Number Theory as a way to know exactly how b goes into a. Without proving that you can always do this with two such numbers a and b, there are a couple of ways to obtain the equation a = qb + r which can clearly be done regardless of the numbers chosen. One way would be to subtract b from a (or add b to a if a < 0) as many times as possible without going less than zero (or greater than zero if a < 0). Count how many times you can perform the subtraction and that’s q. The leftover bit is r. For example, given a = 55 and b = 12, we can do something like this: 55 − 12 = 43 43 − 12 = 31 1 31 − 12 = 19 19 − 12 = 7 We performed the subtraction 4 times, and were left with 7 at the end, so 55 = 4 · 12 + 7. You could also do long division like in grammar school. The number you get above the division bar is q and the remainder is r. (What happens in the first case if b ≤ 0?) Once again, the division algorithm replaces the division operation in Number Theory as a way to know exactly how b goes into a. We separate the case where the remainder r is equal to zero. If r = 0 then a = qb, indicating that b goes into a evenly, and we introduce a special notation: Definition 1 We say that b divides a if a = qb for some integer q. We write b | a, and say that b is a factor (also called divisor) of a, and a is a multiple of b. 1.1 Some comments on Integer Division Note that in the last definition we say that the statement (b | a) is equivalent to a (a = qb) but not to ( = q). This is because in Number Theory, there is b a no division operator, and has no meaning...technically. This isn’t to say b a that you are wrong to assume that = q when you are told that b | a, it b just means that you are now working outside Number Theory. As an example of how the division algorithm can replace the division operation, think of how a computer evaluates the expression ’a / b’ when a and b are both integers. The ’/’ operator always returns an integer, even when b does not divide a. The integer that it returns is the same q from a = qb + r. So what you thought was the division operator for integer type variables is really just an application of the division algorithm. It should also be mentioned that the division algorithm is not really an algorithm–the equation which is guaranteed to exist by Theorem 1 is the result of an algorithm. 2 Primes and Composites Recall that if b | a, then b is a factor of a. For example, the set of all of the factors of 24 is {1, 2, 3, 4, 6, 8, 12, 24}. 2 Definition 2 For any integer n > 1, n has at least two factors, namely itself and 1. An integer p > 1 is called prime if it has itself and 1 as its only factors. Otherwise, it is called composite The set of primes, {2, 3, 5, 7, 11, 13, 17, 23, ...} is countably infinite. It is not too difficult to imagine that, if you write n as the product of two of its factors x and y, then rewrite x and y each as the product of two of their factors, and so on, you may get to the point where one of the factors in the product is prime and can’t be rewritten differently (except as itself times 1). In fact, if you do this, you will always eventually get to the point where all of the factors are prime, and you cannot decompose the number n any further. This is called the prime factorization of n For example: 24 = 6 · 4 = (3 · 2) · (2 · 2) = 2 · 2 · 2 · 3 What if instead of starting with 24 = 6 · 4, we wrote 24 = 8 · 3? Would we end up with the same prime factorization? 24 = 8 · 3 = (4 · 2) · 3 = ((2 · 2) · 2) · 3 = 2 · 2 · 2 · 3 In fact, we will always end up with same prime factorization of an integer n > 1, no matter what n is, and no matter in what way we decide to decompose n. This is stated precisely by the Fundamental Theorem of Arithmetic. Theorem 2 (The Fundamental Theorem of Arithmetic) Every integer n > 1 can be written as a product of primes uniquely, up to the order of the primes. This means that any number can be written uniquely as n = pn1 1 pn2 2 pn3 3 . . . pnk k . . . , where pi represents the ith prime number (i.e. p1 = 2, p2 = 3, p3 = 5, etc.) and all the ni are integers greater than or equal to zero. If, for example, you have an expression A = B, then Ak Bk B1 B2 B3 2 A3 A = p1A1 pA 2 p3 . . . pk . . . , and B = p1 p2 p3 . . . pk . . . , and by the Fundamental Theorem of Arithmetic, you can conclude that ∀ i, Ai = Bi 3 It is convenient to write the generalized prime factorization in its compact form: ∞ Y n= pni i = pn1 1 pn2 2 pn3 3 . . . pnk k . . . , i=1 Even though the product goes until infinity, there is some point after which all ni = 0. 3 Greatest Common Divisor and Least Common Multiple These terms should sound familiar. Definition 3 (Greatest Common Divisor) Let a and b be integers which are not both zero. The largest integer d that divides both a and b is denoted by gcd(a, b). gcd(a, b) is a function from Z × Z → Z and d = gcd(a, b) It should be noted that gcd(a, 0) = a, and you should justify to yourself why that satisfies the definition. You may be familiar with the greatest comm mon divisor from arithmetic. When you need to reduce a fraction , you n divide top and bottom by gcd(m, n). For example, to reduce the fraction: 1 600 23 · 3 · 52 23 · 3 · 52 23 · 3 · 5 5 5 = 4 = 4 · = = 1 1680 2 ·3·5·7 2 ·3·5·7 2·7 14 23 · 3 · 5 you divide the numerator and denominator by 23 ·3·5 = 120 = gcd(600, 1680). It shouldn’t be too difficult to see that gcd(m, n) = ∞ Y min(mi ,ni ) pi i=1 Definition 4 (Least Common Divisor) Let a and b be positive integers. The smallest positive integer d that can be divided by both a and b is denoted by lcm(a, b). lcm(a, b) is a function from N × N → N and d = lcm(a, b) The least common multiple arises when you take the sum of two frac1 1 tions. The denominator of the sum of two fractions and will always be x y lcm(x, y) if you reduce the answer to lowest terms. For example: 4 1 1 600 1680 600 + 1680 + = + = 1680 600 1680 · 600 600 · 1680 600 · 1680 = 23 · 3 · 52 + 24 · 3 · 5 · 7 (23 · 3 · 5) · (5 + 2 · 7) = 3 3 2 4 (2 · 3 · 5 ) · (2 · 3 · 5 · 7) (2 · 3 · 5) · (24 · 3 · 52 · 7) = 19 (5 + 2 · 7) = 4 2 (2 · 3 · 5 · 7) 8400 From this you should see that lcm = ∞ Y max(mi ,ni ) pi i=1 You may also notice from the fifth equation of the example that a · b = gcd(a, b) · lcm(a, b) and that to pull out a common factor from (A + B) you can pull out all common factors by (A + B) = gcd(A, B) · 3.1 ¡ ¢ A B + gcd(A, B) gcd(A, B) The Euclidean Algorithm The Euclidean Algorithm is a slick little number that can be used to find the gcd of very large numbers relatively quickly, and it depends on the following theorem: Theorem 3 Let a = qb + r, then gcd(a, b) = gcd(b, r) Proof: Denote the set S(a,b) = {d | (d | a) ∧ (d | b)} be the set of all common divisors of a and b. Likewise, the set S(b,r) is the set of all common divisors of b and r. If we can show that S(a,b) = S(b,r) , then we’ll have shown that gcd(a, b) = gcd(b, r) since the largest element of S(a,b) must also be the largest element of S(a,b) . So, if d ∈ S(a,b) then d | a and d | b. If d | b then d | qb. If d | qb and d | a then d | (a − qb) 5 Since a = qb + r, a − qb = r, therefore, d | r So, d | b and d | r therefore, d ∈ S(b,r) If d ∈ S(b,r) , then d | b and d | r. If d | b then d | qb. If d | qb and d | r then d | (qb + r) Since a = qb + r, d | a So, d | a and d | b therefore, d ∈ S(a,b) Therefore, S(a,b) = S(b,r) and it follows that gcd(a, b) = gcd(b, r) So, to perform the Euclidean Algorithm to find the gcd(a, b), (where a > b) write a = q1 b + r1 and you’ll have gcd(a, b) = gcd(b, r). Now write b = q2 r1 + r2 to get gcd(a, b) = gcd(b, r1 ) = gcd(r1 , r2 ), and so on, until you get down to the gcd(a, b) = gcd(b, r1 ) = gcd(r1 , r2 ) = . . . = gcd(rn−1 , rn ) = gcd(rn , 0) = rn . This is best understood by example, of which there are plenty in the book. After you’ve done a couple, you’ll be an expert. An even simpler way is as follows: Write (a, b). Underneath that, write (a − b, b) if a > b or (a, b − a) if b > a. Repeat until you get to (x, x). Then gcd(a, b) = x. Here’s an example, solving the same problem as in Example 1 on page 129 of the textbook. (414, 662) (414, 248) (166, 248) (166, 82) (84, 82) (2, 82) (2, 80) (2, 78) .. . (2, 2) Therefore, gcd(414, 662) = 2. In fact, feel free at any point in the algorithm to stop if it is obvious what the gcd is. For example, at (2, 82) above, it is clear that gcd(2, 82) = 2. 6 4 Modular Arithmetic All of this development of Number Theory really leads up to this. The way that we’ve treated division is so cool, that we can actually develop an entire system of arithmetic based on the remainder r from a = qb + r. We do this by defining an operator and a relation. Definition 5 (Mod Operator) Let the operator mod, or % which takes an an integer a and a natural number m be defined as amodm = r (or a%m = r) where r is the remainder after division of a by m. With this definition, we could rewrite the division algorithm as a = qm + amodm. Please note that, just as in the division algorithm, m must be a positive integer, but a can be anything. Now the relation: Definition 6 (Congruency Modulo m) Two numbers a and b are congruent modulo m iff amodm = bmodm. We write a ≡ b (mod m). Please study these definitions and understand their difference as well as their similarity. A couple of thoughts on the congruency relation. First, it is important to note that what we have just defined is the ’≡’ part. The ’ (mod m)’ part really just refers to the ’≡’ symbol, letting the reader know which equivalence relation is being talked about. It may be helpful to realize that there are some who write ”a is congruent to b modulo m” like a ≡m b. Perhaps this makes it easier to understand that a ≡ b (mod 3) is not the same as a ≡ b (mod 5). We’ve defined a whole family of relations which depend on which m you pick. For example, 15 is congruent to 8, 22, -6 and -13 modulo 7 (they all have remainder 1 when divided by 7), but it’s not congruent to any of them modulo 5. The following 5 statements about integers are all equivalent: 1. a ≡ b (mod m) 2. a−b =k m 3. m | (a − b) 4. a mod m = b mod m -or- a%m = b%m 5. a = mk + b 7