Elementary Number Theory
Congruences Modular Arithmetic Congruence The notion of congruence allows one to treat remainders in a systematic manner. For each positive integer greater than 1 there is an arithmetic mod n that mirrors ordinary arithmetic, but is finite, since it involves only the remainders 0, 1,..., n 1 occuring on division by n. Definition Integers a and b are said to be congruent mod n, written a b mod n, if they leave the same remainder on division by n. In other words, a b mod n, if n divides a b.
Congruences Definition The set of remainders {0, 1,..., n 1} is called the least sytem of residues modulo n. We denote the system of residues modulo n bu Z n. A set of integers a 1,..., a n form a complete system of residues modulo n if these are congruent to {0,..., n 1} modulo n. The integers that leave remainder r on division by n form what is called the congruence class of a, {nk + a : k Z}, denoted by nz + a. For example, 2Z is {even numbers} and 2Z + 1 is {ood numbers}. Each congruence class is a set of equally spaced points along the real line.
Examples Examples 8 3 mod 5, since 8 3 = 1 5 Complete set of residues modulo 5: {0, 1, 2, 3, 4} but also { 5, 11, 32, 13, 24} Fact: A set of n integers a 1,..., a n forms a complete set of residues modulo n if and only if NO two integers a i and a j are congruent modulo n, i.e. a i a j = k n does not hold for a k Z. One can add and multiply congruences very much like one can add and multiply integers:modular Arithmetic.
Modular Arithmetic Basic Rules a a mod n Example If a b mod n, then b a mod n. If a b mod n and b c mod n, then a c mod n. If a b mod n and c d mod n, then a + c b + d mod n and ac bd mod n. If a b mod n, then a k b k mod n. 3 8 mod 5 and 8 23 mod 5 gives 3 23 mod 5 3 8 mod 5 and 1 11 mod 5 gives 4 19 mod 5 3 8 mod 5 and 1 11 mod 5 gives 3 88 mod 5
Modular Arithmetic Division If a b mod n and c d ac bd mod n. mod n, then In particular: If a b mod n, then ac bc mod n. In contrast to the integers, one has to be careful about cancelling common factors in modular arithmetic! 15 2 20 2 mod 10 BUT 15 20 mod 10. 6 16 mod 5 is 2 3 2 8 mod 5 is the same as 3 8 mod 5. 6 4 0 mod 12, BUT 6 6 mod 12 and 4 4 mod 12.
Cancellation of factors in modular arithmetic Lemma Suppose a b mod n. Then a b mod n gcd(c,n). Check it in our example: 15 2 20 2 mod 10, gcd(2, 10) = 2 15 20 mod 5. Corollary Suppose gcd(d, n) = 1. Then a c b c a b mod n. mod n implies Suppose p is a prime number. If c is not a multiple of p, then Then a c b c mod p implies a b mod p. Moral: Congruences modulo a prime number p behave very differently from congruences modulo a composite number.
Congruences Modular Arithmetic Definition Integers a and b are said to be congruent mod n, written a b mod n, if they leave the same remainder on division by n. In other words, a b mod n, if n divides a b. Remark What is 3 x mod 7? Answer: x = 4. General case: k mod n is n k k mod n n 0 mod n is the same as n k + k 0 mod n. Therefore, n k k mod n.
Congruences Modular Arithmetic Cancelling Factors in congruences Suppose ac bc mod n. Then a b mod Special case Suppose gcd(c, n) = 1. Then a c b c a b mod n. n gcd(c,n). mod n implies Suppose p is a prime number and c is not a multiple of p. Then a c b c mod p implies a b mod p.
Linear congruences Linear congruences The equation ax b mod n has a solution if and only if d = gcd(a, n) divides b. If d = gcd(a, n) divides b, then it has d mutually incongruent solutions modulo n: x 0, x 0 + n d, x 0 + 2n d,..., x 0 + (d 1)n d, where x 0 is the particular solution determined from the Euclidean algorithm. Corollary Suppose gcd(a, n) = 1. Then ax b mod n has a unique solution.
Linear congruences Solution Find y Z such that ay 1 mod n, i.e. find the multiplicative inverse of a modulo n. Use the Euclidean algorithm to find such an y. Multiply the linear congrunce ax b mod n with the multiplicative inverse y. Then yax yb mod n, which yields x yb mod n.
Linear congruences Example 37x 15 mod 49. gcd(37, 49) = 1 implies that the equation has exactly ONE solution. Find the multiplicative inverse of 37 modulo 49, i.e. 37y 1 mod 49. Euclidean algorithm: 49 = 37 + 12, 37 = 3 12 + 1. Thus 1 = 37 3.12 = 37 3(49 37) = 4 37 3 49. 4 is the multiplicative inverse of 37 modulo 49. 37x 15 mod 49, therefore 4 37x 15 mod 49, i.e. x 11 mod 49.
Linear congruences Example 18x 8 mod 14. gcd(14, 18) = 2 implies that the equation has TWO solutions. 2 9x 2 4 mod 2 7 is equivalent to 9x 4 mod 7 because gcd(2, 14) = 2. Find the multiplicative inverse of 9 modulo 7, i.e. 9y 1 mod 7. Euclidean algorithm: 9 = 7 + 2, 7 = 3 2 + 1. Thus 1 = 4 7 3 9. 3 is the multiplicative inverse of 9 modulo 7, i.e. 3 4 mod 7. 9x 4 mod 7, therefore 4 9x 4 4 mod 7, i.e. x 0 2 mod 49. The second solution: x 1 = x 0 + 14/2 = 2 + 7 = 9.
Pascal s triangle
Pascal s triangle modulo 2 Pascal s Triangle mod 2
Binary representation of integers Motivation G. W. Leibniz, one of the inventors of calculus and contempary of Newton, was the first to express integers in terms of powers of 2. In 1671 Leibniz invented a machine that could execute all four arithmetical operations, which later was actually build. Binary representations are ubiquitious nowadays, because that s the way computers operate and all our data are stored on DVD, flashdrive,...! In other words our digital world has only two fingers or in Latin: two digits. We are going to use them in our computations of congruences!
Binary Representation Procedure Instead of powers of 10 we want to write a number in terms of powers of 2. The first few powers of 2 are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,... Let us write 984 = 9 10 2 + 8 10 + 4 10 0 in powers of 2: Find the largest power of 2 that does not exceed 984 (that is 512 = 2 9 in this case), and then procede successively with smaller powers of 2 as follows: 984 = 512 + 472, 472 = 256 + 216, 216 = 128 + 88, 88 = 64 + 24, 24 = 16 + 8. 984 = 2 9 +2 8 +2 7 +2 6 +0 2 5 +2 4 +2 3 +0 2 2 +0 2 1 +0 2 0 (984) 2 = 1111011000
Binary Representation Summary A 1 in our binary representation means we are including the power of 2 and a 0 that we are excluding this power of 2. Examples What are the binary expansion of 7, 11, 15, 25 and of 6, 10, 14, 20? The answers are as follows: (7) 2 = 111, (11) 2 = 1011, (15) 2 = 1111, (25) 2 = 11001 (6) 2 = 110, (10) 2 = 1010, (14) 2 = 1110, (20) 2 = 10100. What is the emerging pattern? odd numbers have a 1 as last digit and even numbers a 0 in the last digit of their binary expansions.
Linear congruences and Chinese Remainder Theorem Linear congruences The equation ax b mod n has a solution if and only if d divides b, where d is the gcd(a, n). If d divides b, then it has d mutually incongruent solutions modulo n: x 0, x 0 + n d, x 0 + 2n d,..., x 0 + (d 1)n d. Corollary Suppose gcd(a, n) = 1. Then ax b mod n has a unique solution. Idea The linear congruence is equivalent to the linear Diophantine equation ax ny = b.
Linear congruences and Chinese Remainder Theorem Idea By the result about linear Diophantine equations we have that it is soluble if and only if d b. Furthermore, the solutions are in this case: Suppose x 0, y 0 are solutions, then any other solution is of the form x = x 0 + n d t and y = y 0 + n d t for t = 0, 1,..., d 1. Example 18x 8 mod 14 We have to find integers x, y such that 18x 14y = 8. gcd(18, 14) = 2 Therefore we can solve 18x 14y = 2 with particular solution is x 0 = 4 and y 0 = 5. Thus 18 16 8 mod 14 and the other solution is 2 14/2 = 5 9 mod 14.
Linear congruences and Chinese Remainder Theorem Chinese Remainder Theorem Let n 1 and n 2 be two integers with gcd(n 1, n 2 ) = 1. Suppose a 1 and a 2 are integers. Then the simultaneous congruences x a 1 mod n 1 and x a 2 mod n 2 has exactly one solution x with 0 x < n 1 n 2. The proof provides the method to solve these kind of equations. Therefore, we discuss it in a particular example. Example What are the solutions to x 8 mod 11 and x 3 mod 19?
Linear congruences and Chinese Remainder Theorem Example x 8 mod 11 and x 3 mod 19 The solution to the first congruence are numbers of the form x = 11y + 8. Substitute this into the second congruence: 11y + 8 3 mod 19 11y 14 mod 19. The solution is y 1 3 mod 19. Solutions to the original congrunence via x 1 = 11y 1 + 8 = 11 3 + 8 = 41. Check our solution: (41 8)/11 = 3 and (41 3)/19 = 2.