Midterm #: practice MATH Intro to Number Theory midterm: Thursday, Nov 7 Please print your name: Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand. Problem. For unknown reasons, the high priest of number theory has banned usage of the Euclidean algorithm. With the help of the Chinese remainder theorem, determine the modular inverse of 49 modulo 666. Note that 666 = 9 7. We rst compute 49 modulo each of ; 9; 7. That's super easy: 49 (mod ), 49 5 (mod 9) and 49 (mod 7). By the Chinese remainder theorem, 49 97[(9 7) mod +7[( 7) mod 9 5 +9[( 9) mod 7 +740 6077 (mod666): Problem. Compute 7 (mod 90) in the following three dierent ways: (a) Directly, using binary exponentiation. (b) With the help of Euler's theorem. (c) With the help of the Chinese remainder theorem (as well as Euler's theorem). (a) Modulo 90, we have 7 = 49, 7 4 = 49 6, 7 8 6, 7 6 6, 7, 7 64 6. Therefore, 7 = 7 64 7 7 8 7 4 7 7 6 6 49 7 7 (mod 90). (b) Since 90 = 5, we nd (90) = 90 5 = 4 so that Euler's theorem tells us that 7 4 (mod 90). Since 5 (mod 4), we have 7 7 5 = 7 8 7 4 7 7 6 49 7 7 (mod 90).
(c) Notice that 90 = 5, where ; 9; 5 are pairwise coprime. Computing 7 modulo each of ; 9; 5 is much easier (note that (9) = 9 = 6 so that, by Euler's theorem 7 6 (mod 9); on the other hand, 7 4 (mod 5)): 7 (mod ); 7 7 ( ) (mod 9); 7 7 (mod 5): By the Chinese remainder theorem, 7 9 5 [(9 5) mod + 5 [( 5) mod 9 + 9 [( 9) mod 5 45 + 0 + 08 7 (mod 90): Comment. While this might seem like the most involved approach (it certainly requires the most expertise), observe that the actual computations are much simpler than in the other cases (because we are operating modulo very small numbers). Problem. Note that = 7 9. (a) Modulo, what do we learn from Euler's theorem? (b) Using the Chinese remainder theorem, show that x 44 (mod ) for all x coprime to. (c) Compare the two results! Bonus: Can you come up with a strengthening of Euler's theorem? (a) Since () = 7 9 = 88, we learn that x 88 (mod ) for all x that are coprime to. (b) By the Chinese remainder theorem, the congruence x 44 (mod ) is true for all x coprime to (or, equivalently, all x coprime to both 7 and 9) if and only if the two congruences x 44 (mod 7) and x 44 (mod 9) are true for all such x. By Fermat's little theorem, we have x 6 (mod 7) and hence x 44 (x 6 ) 9 (mod 7). Likewise, x 8 (mod 9) implies that x 44 (x 8 ) 8 (mod 9). (c) If x 44 (mod ), then x 88 = (x 44 ) (mod ). This means that Euler's theorem is weaker than the congruence we obtained using the Chinese remainder theorem. This leads us to the following strengthening of Euler's theorem. If the prime factorization of n is n = p k p r k r, then x f(n) (mod n), where f(n) = lcm('(p k ); '(p k ); :::; '(p r k r )): Advanced comment. This f(n) is almost the minimal value (n) such that x (n) (mod n). The only improvement that can be made is that, in the above, '( m ) may be replaced with '(m ) if m >. This is known as Carmichael's theorem.
Problem 4. Let a; b be positive integers. (a) Suppose that x a (mod n) and x b (mod n). Show that x gcd(a;b) (mod n). (b) Use the previous result to nd all solutions to x 0 (mod 07). (c) On the other hand, there are 6 solutions to x 0 (mod 06). What is dierent in this case? (a) By Bezout's identity, we nd integers r; s such that ra + sb = gcd(a; b). Hence, x gcd(a;b) = x ra+sb = (x a ) r (x b ) s r s (mod n): (b) Note that a solution x is necessarily coprime to 07. (Why?!) By Fermat's little theorem, x 06 (mod 07). Since gcd(06; 0) =, we conclude that x (mod 07). Since 07 is a prime, this congruence has only the solutions x (mod 07). (We established this in Problem of Homework 4. Make sure that you recall the argument and why it is crucial that 07 is a prime.) (c) Again, a solution x is necessarily coprime to 06. By Euler's theorem, x 576 (mod 06). Since gcd(576; 0) =, we conclude that x (mod 06). However, 06 is not a prime and so this congruence actually has more solutions than just x (mod 06). Comment. In fact, it has the 6 solutions ; 7; 4; 449; 559; 575; 88; 007; 009; 5; 44; 457; 567; 58; 889; 05 modulo 06. Clearly, each of these also solves x 0 (mod 06). Problem 9 below makes it transparent where these extra solutions are coming from. In short, by the Chinese remainder theorem, the congruence modulo 06 = 5 7 breaks into congruences modulo 5, and 7; in each of these three cases, we get at least the two solutions, which we can combine in = 8 dierent ways to get 8 solutions modulo 06. That we actually have 6 = 4 solutions modulo 06 is due to the fact that x (mod 5 ) actually has 4 instead of just solutions (namely, x ; 5 (mod 5 )). Problem 5. (a) You wonder whether ; 660; 9 is a prime. A (comparatively) quick computation shows that 6608 064778 (mod 6609). What do you conclude? (b) You wonder whether 9; 96; 80 is a prime. A quick computation shows that 996800 (mod 99680). What do you conclude? (a) This proves that 6609 is not a prime. Because, if it was a prime, then 6608 (mod 6609) by Fermat's little theorem. [Indeed, 6609 = 69 5; but nding that factorization is a more dicult task! (b) We still don't know whether 99680 is a prime or not. There is two possibilities: either 99680 is a prime, or 99680 is a pseudoprime to base (people also say that is a Fermat liar in that case). [Actually, 99680 is a prime.
Problem 6. (a) Using Fermat's little theorem and base, show that 4 is not a prime. (b) Is 4 a pseudoprime to the base? These computations are tedious to do by hand. Do make sure though that the idea and the procedure are clear. (a) 40 56 / (mod 4) so that, by Fermat's little theorem, 4 cannot be a prime. Of course, computing that 40 56 (mod 4) requires some work. In the absence of knowing the prime factorization of 4, we resort to direct binary exponentiation (see comment below) and 40 = (00000) = 56 + 64 + 6 + 4. Here are the intermediate values we get modulo 4: 9, 4 8, 8 8, 6 45, 9 (so that, now, the values repeat), 64 8, 8 8, 56 45. Useful observation. Note that we could have saved some work by exploiting (mod 4), which implies 0 (mod 4). Since 40 0 (mod 0), we nd that 40 0 = 8 56 (mod 4). (b) We need to compute 40 (mod 4). We proceed using binary exponentiation as in the previous part. The values we get modulo 4 are: = 4, 4 = 6, 8 = 56, 6 = 64, = 4, so that, again, values repeat. In the end, we nd that 40 (mod 4). This means that 4 is a pseudoprime to the base (because we already know that 4 is not an actual prime). Useful observation. Again, we can save a lot of work by exploiting (mod 4), which implies 0 (mod 4). As before, we conclude that 40 0 = 8 (mod 4). Comment. If we know the factorization of 4 then we can cut down on our work a little bit by using the Chinese remainder theorem and Euler's theorem (but realize that if we have to ask questions like whether 4 is a prime, then we wouldn't know this factorization and wouldn't be able to apply these theorems). Problem 7. (a) Among the numbers ; ; :::; 06, how many are coprime to 06? (b) Carefully state Euler's theorem. (c) If the prime factorization of n is n = p k p r k r, what does (n) evaluate to? (d) Carefully state Wilson's theorem. (a) This just asks for (06). (b) If n > and gcd(a; n) =, then a (n) (mod n). k (c) If the prime factorization of n is n = p k p r r, then (n) = n p pr. (d) If p is a prime, then (p )! (mod p). Problem 8. (a) What does it mean for n to be a pseudoprime to base a? (b) What does it mean for n to be an absolute pseudoprime? (c) Outline the Fermat primality test. What makes this a heuristic test? 4
(a) It means that n is composite but satises a n a (mod n). In other words, it behaves like a prime would by Fermat's little theorem. Sometimes the condition a n a (mod n) is replaced with a n (mod n). That makes no dierence unless gcd(a; n) =/ (in which case we learned about a divisor of n). (b) These are numbers which are pseudoprime to any base a >. (c) Fermat primality test: Input: number n and parameter k indicating the number of tests to run Output: not prime or possibly prime Algorithm: Repeat k times: Pick a random number a from f; ; :::; n g. If a n / (mod n), then stop and output not prime. Output possibly prime. The test is heuristic because it is not designed to decide with absolute certainty whether a number is a prime. More specically, if it claims that a number is composite, then we actually do have certainty that the number is indeed composite (but don't know its factors). But the test is unable to prove that a number is prime; if we choose the number of iterations k large enough, then we have strong reason to believe that n is a prime (if we do not deal with an absolute pseudoprime [which are very rare then there is only a probability of k that we mistakenly label a composite number as probably prime). Problem 9. (a) Using the Chinese remainder theorem, determine all solutions to x (mod 05). (b) Can you predict how many solutions the congruence x (mod 0) is going to have? (a) Note that 05 = 5 7. By the Chinese remainder theorem, x is a solution to x (mod 05) if and only if x is a solution to the three congruences x (mod ); x (mod 5); x (mod 7): Since ; 5; 7 are primes each of these only has the obvious solutions x. (Again, we established this in Problem of Homework 4.) Using the Chinese remainder theorem, these combine in = 8 dierent ways to a solution modulo 05. For instance, one the 8 possibilities is x (mod ); x (mod 5); x (mod 7) () x 5 7 [(5 7) mod + 7 [( 7) mod 5 5 [( 5) mod 7 = 70 + 5 4 (mod 05): Corresponding to it is the negative case x (mod ), x (mod 5), x (mod 7) which is equivalent to x 4 (mod 05). Likewise, we determine all 8 solutions as follows: x (mod ); x (mod 5); x (mod 7) () x (mod 05) x (mod ); x (mod 5); x (mod 7) () x 9 (mod 05) x (mod ); x (mod 5); x (mod 7) () x 4 (mod 05) x (mod ); x (mod 5); x (mod 7) () x 4 (mod 05) x (mod ); x (mod 5); x (mod 7) () x 4 (mod 05) x (mod ); x (mod 5); x (mod 7) () x 4 (mod 05) x (mod ); x (mod 5); x (mod 7) () x 9 (mod 05) x (mod ); x (mod 5); x (mod 7) () x (mod 05) 5
Note that, because each case has a negative, we only need to compute 4 of these 8 cases. In summary, x (mod 05) has exactly the 8 solutions x ; 9; 4; 4 modulo 05. (b) Since 0 = 5 7, we can again use the Chinese remainder theorem and argue as in the previous case. There is just one dierence: the congruence x (mod ) only has solution (because (mod )). Hence, we nd that the congruence x (mod 0) has = 8 solutions. A variation. On the other hand, x (mod 5 7 9) will have = 6 solutions. Problem 0. (a) Which number is represented by the continued fraction [; ; ; ; ;? (b) Determine all convergents of [; ; ; ; ;. (c) Which number is represented by the innite continued fraction [; ; ; ; ; ; ; ; :::? (d) Compare, numerically, the rst six convergents (computed above) to the value of the innite continued fraction. (a) [; ; ; ; ; = + + + + + = 4 0 Comment. Of course, we can simplify this continued fraction directly. But that is a bit time consuming and prone to errors. A better is way is to compute the convergents recursively as we do in the next part. (b) The convergents are C 0 =, C = [; = + =, C = [; ; = + We can continue like that but the computations will get more involved. Instead, we should proceed recursively. Recall from class that the convergents C n = pn of [a q 0 ; a ; a ; ::: are characterized by n + = 4. p k = a k p k + p k with p = 0; p = and q k = a k q k + q k with q = ; q = 0 : The corresponding calculations of p n and q n are as follows: (c) Write x = [; ; ; ; ; ; ; ; :::. Then, x = + n 0 4 5 a n p n 0 4 5 4 q n 0 8 0 C n + + 4 + + ::: 8 5 4 0 = +. + x The equation x = + simplies to x = x. Further (note that, clearly x =/ so that x + =/ 0) + x + x simplies to (x )(x + ) = x or x x = 0, which has the solutions x = p 4 + 8 = p. Since + p.66 and p 4 p 0.66, we conclude that [; ; ; ; ; ; ; ; ::: = +. (d) C 0 =, C = =.5, C = 4., C = 8 =.75, C 4 = 5.64, C 5 = 4 0.67 6
These values quickly approach + p.66 in the expected alternating fashion. Problem. (a) Express the numbers 5 7 and as a simple continued fraction. 9 (b) Is this the unique simple continued fraction representing 5 9? Explain! (a) The simplest way to obtain the continued fraction for 5 is via the Euclidian algorithm: 9 5 = 9 + 59; 9 = 59 + 6; 59 = 6 + ; 6 = + 5; = 5 + ; 5 = 5 + 0 Hence, 5 = [; ; ; ; ; 5. 9 To determine a simple continued fraction for 7 using the Euclidian algorithm applied to 05. 7 05, we rst write = + = + = 05 + ; 05 = 9 + 6; = 6 + 5; 6 = 5 + ; 5 = 5 + 0: 05. We then proceed Combined, 7 = [ ; ; 9; ; ; 5. (b) No, a nite continued fraction can always be expressed in two ways because of the simple relation [a 0 ; a ; a ; :::; a n = [a 0 ; a ; a ; :::; a n ;, assuming a n >. In this case, we also have 5 = [; ; ; ; ; 4;. 9 It is also a very good idea to review the problems from Homework 5 as well as the previous practice problems. 7