Modular Arithmetic

Modular Arithmetic

Modular Arithmetic Adithya B., Brian L., William W., Daniel X. 9/2 §1 Chinese Remainder Theorem Oftentimes, we need to handle congruences modulo composite numbers, e.g. modulo 6, or modulo 210, etc. The Chinese Remainder Theorem is a useful tool that allows us to transfer from multiple congruences to a single congruence: Theorem 1.1 (Chinese Remainder Theorem) Let a1; a2; : : : ; an be pairwise coprime positive integers (that is, no two of these numbers share a common factor greater than one), and b1; b2; : : : ; bn be any integers. Then the system of n congruences x ≡ b1 (mod a1); x ≡ b2 (mod a2); ··· ; x ≡ bn (mod an) is equivalent to the congruence x ≡ k (mod a1a2 ··· an) for some integer k. That is, x satisfies all n congruences above if and only if x ≡ k (mod a1a2 ··· an). Note that this is an existence theorem: it does not tell us how to find k. For example, the theorem tells us that x ≡ 1 (mod 2); x ≡ 2 (mod 3); x ≡ 3 (mod 5); is equivalent to x ≡ k (mod 30) for some integer k, but it does not tell us what k is. (We can manually find that k = 23.) The Chinese Remainder Theorem is especially powerful because it allows us to collate multiple congruences into a single congruence without having to actually solve the system of congruences. This will be essential for the problems below. Example 1.2 (2012 AIME II #12) For a positive integer p, define the positive integer n to be p-safe if n differs in absolute value by more than 2 from all multiples of p. For example, the set of 10-safe numbers is f3; 4; 5; 6; 7; 13; 14; 15; 16; 17; 23;:::g. Find the number of positive integers less than or equal to 10; 000 which are simultaneously 7-safe, 11-safe, and 13-safe. 1 Adithya B., Brian L., William W., Daniel X. (9/2) Modular Arithmetic Solution. The p-safe condition translates nicely into modular arithmetic. In order for n to be 7-safe, it has to be more than two away from any multiple of 7. This means it has to be congruent to 3 or 4 modulo 7. Conversely, if n is congruent to 3 or 4 modulo 7 then it is more than 2 away from the nearest multiple of 7. Similarly, n is 11-safe if and only if it is congruent to 3; 4; 5; 6; 7, or 8 modulo 11, and n is 13-safe if and only if it is congruent to 3; 4; 5; 6; 7; 8; 9, or 10 modulo 13. For n to be simultaneously 7-safe, 11-safe, and 13-safe, all of the following congruences must be satisfied: • n ≡ 3; 4 (mod 7); • n ≡ 3; 4; 5; 6; 7; 8 (mod 11); • n ≡ 3; 4; 5; 6; 7; 8; 9; 10 (mod 13): Moreover, 7, 11, and 13 are pairwise relatively prime (they are all prime), so we can use the Chinese Remainder Theorem to splice together these conditions. For example, the congruences • n ≡ 4 (mod 7); • n ≡ 8 (mod 11); • n ≡ 3 (mod 13): have a unique solution modulo 7 · 11 · 13 = 1001. To find all possible solutions modulo 1001, we need to pick a residue modulo 7, a residue modulo 11, and a residue modulo 13; each such choice results in exactly one residue modulo 1001. With our list above, we find that this can be done in 2 · 6 · 8 = 96 ways. So there are 96 residues modulo 1001 that are 7-safe, 11-safe, and 13-safe. We now want to find the number of positive integers at most 10; 000 that work. From our work above, we see that: • There are 96 working integers in f1; 2;:::; 1001g, • There are 96 working integers in f1002; 1003;:::; 2002g, • ..., • There are 96 working integers in f9010; 9011;:::; 10010g. So there are 960 working integers from 1 to 10010, inclusive. We just need to examine the integers 10001;:::; 10010 and subtract any overcounts to find the final answer. Note that 10010 is a multiple of 7, 11, and 13. The next smallest multiples of 7, 11, and 13 are 10003, 9999, and 9997, respectively. From this, we see that the only working integers from 10001 to 10010 are 10006 and 10007. So we have two overcounts, and the number of positive integers less than or equal to 10; 000 which are 7-safe, 11-safe, and 13-safe is 960 − 2 = 958 . 2 Adithya B., Brian L., William W., Daniel X. (9/2) Modular Arithmetic Example 1.3 (2011 AIME II #14) There are N permutations (a1; a2; : : : ; a30) of 1; 2;:::; 30 such that for m 2 f2; 3; 5g, m divides an+m − an for all integers n with 1 ≤ n < n + m ≤ 30. Find the remainder when N is divided by 1000. Solution. We're given three different values of m to use; let's investigate them separately. For m = 2, the condition implies that a1 ≡ a3 ≡ · · · ≡ a29; a2 ≡ a4 ≡ · · · ≡ a30 (mod 2) Since the ai need to be a permutation of (1; 2;:::; 30), with 15 odd numbers and 15 even numbers, this implies that a1; a3; : : : ; a29 are all of the opposite parity as a2; a4; : : : ; a30. Thus we can choose that either a1; a3; : : : ; a29 are all even, or a1; a3; : : : ; a29 are all odd. There are 2 ways to do this. Let's take a look modulo 3. The condition gives us a1 ≡ a4 ≡ · · · ≡ a28; a2 ≡ a5 ≡ · · · ≡ a29; a3 ≡ a6 ≡ · · · ≡ a30 (mod 3): Again, since the ai are a permutation of (1; 2;:::; 30), 10 of them congruent are to each of 0; 1, and 2 modulo 3. So we can choose what a1; a4; : : : ; a28 are modulo 3, then pick a different residue for a2; a5; : : : ; a29, and use the last residue for a3; a6; : : : ; a30. We have 3! = 6 ways to do this. Finally, for m = 5 we can use the same logic. We get a1 ≡ a6 ≡ · · · ≡ a26; a2 ≡ a7 ≡ · · · ≡ a27; : : : ; a5 ≡ a10 ≡ · · · ≡ a30 (mod 5): We can choose the residues of a1; a6; : : : ; a26 modulo 5, then pick a different residue for a2; a7; : : : ; a27, and so on up to a5; a10; : : : ; a30. There ae 5! = 120 ways to assign residues modulo 5. We have now chosen a residue for each ai modulo 2; 3, and 5; by the Chinese Remainder Theorem this results in a unique residue modulo 30, and hence a unique element of f1; 2;:::; 30g. So our choices uniquely define the sequence (a1; a2; : : : ; a30): We're not done yet; we need to check if this sequence is a permutation. That is, we need to check that no two elements are equal. What happens if ai = aj? This means that ai ≡ aj (mod 2), so that i ≡ j (mod 2). We see this because a1 ≡ a3 ≡ · · · ≡ a29 6≡ a2 ≡ a4 ≡ · · · ≡ a30 (mod 2): Similarly, ai ≡ aj (mod 3), so i ≡ j (mod 3), and since ai ≡ aj (mod 5) we have i ≡ j (mod 5). By the Chinese Remainder Theorem, we have i ≡ j (mod 30). But i and j are between 1 and 30, so this forces i = j. Hence we conclude that our sequence is a permutation; no two terms are equal. We had 2! ways to set the residues modulo 2, 3! ways to set the residues modulo 3, and 5! ways to set the residues modulo 5, so the total number of ways is 2! · 3! · 5! = 2 · 6 · 120 = 1440 and the answer is 440 : 3 Adithya B., Brian L., William W., Daniel X. (9/2) Modular Arithmetic §2 Euler's Totient Theorem Euler's Totient Theorem is probably the most important theorem for dealing with exponents in modular arithmetic. Using it, one can compute the residue of large powers of numbers modulo a fixed n without having to resort to techniques such as \looking for patterns." To understand it, first we must know what the totient function is. Definition 2.1. The totient of n, denoted φ(n), is the number of positive integers less than or equal to n which are relatively prime to it. We won't go over it's proof in this class, but the totient is easily computable via the closed form 1 1 1 φ(n) = n 1 − 1 − ··· 1 − p1 p2 pk where p1; p2; : : : ; pk are the primes dividing n, listed without repetition. The proof can be done using Chinese Remainder Theorem on mods p1; : : : ; pk and is left as an exercise to the reader. Theorem 2.2 (Euler's Totient Theorem) Given an integer n > 1 and a natural a relatively prime to n, we have aφ(n) ≡ 1 (mod n) Proof. Denote S the set of residues modn which are coprime with n. By definition, jSj = φ(n). Now, consider the set T = fas (mod n)js 2 Sg, which is the set of the residues multiplied by a. As a is coprime with n, all elements of T are coprime with n as well. Furthermore, no two elements in T are the same, since as ≡ as0 (mod n) =) s ≡ s0 (mod n). So, T is a set of numbers coprime to n with magnitude jT j = jSj = φ(n). Hence, T = S. Of course, as they are the same set, the product of all the elements should be the same too. Hence, Y Y Y Y Y s ≡ t (mod n) =) s ≡ as ≡ aφ(n) s (mod n) s2S t2T s2S s2S s2S =) aφ(n) ≡ 1 (mod n) as desired.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us