Congruences Notes for the San Jose Math Circle, October 5, 2011 by Brian Conrey American Institute of Mathematics Here are some questions to motivate this session. (1) What is the last non-zero digit of 100!? (2) Is there a number whose representation only uses the digit 1 which is a multiple of 2011? (3) What are the possible last two digits of a perfect square? (4) What are the possible last 4 digits of a perfect one-thousandth power? (5) Prove that there is a power of 2 whose last one-million digits are all ones and twos.

1. Introduction

All variables will stand for (..., −3, −2, −1, 0, 1, 2, 3,... ) in these notes. We say that a “divides” b and write a | b if there is an x such that ax = b. In other words, “divides” means “goes into.” Thus, 7 | 35 and 11 - 24.

Let m be a positive integer. We say ‘a is congruent to b modulo m’ and write a ≡ b mod m to mean m | (a − b). For example, 3 ≡ 7 mod 4 21 ≡ −3 mod 12 and so on. Another way to think of it is that a and b have the same remainder when you divide by m. The basic properties of congruences are: If a ≡ b mod m and c ≡ d mod m then a + c ≡ b + d mod m a − c ≡ b − d mod m ac ≡ bd mod m Also, if a ≡ b mod m and a ≡ b mod n then a ≡ b mod [m, n] where [m, n] denotes the least common multiple of m and n. (6) What day of the week will it be one million days after Oct. 29, 2003? (7) Prove that 3099 + 61100 is divisible by 31. (8) What is the last digit of 19981998. (9) What is the last digit of 999 ? (10) Show that ≡ is reflexive, symmetric, and transitive. (11) The Fibonacci sequence is defined recursively by F1 = 1, F2 = 1 and Fn+2 + Fn+1 = Fn. The first few terms of the sequence are 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... . Show that F5n ≡ 0 mod 5. (12) Show that a number is congruent to the sum of its digits modulo 9. Conclude that a number is divisible by 9 if and only if the sum of its digits is divisible by 9. (13) Find a simple divisibility test for divisibility by 11. 1 2

Residue Classes

If x ≡ a mod m then a is called a residue of x to the modulus m. The collection of all residues of a given number x for a modulus m is called a residue class. For example, there are three residue classes for the modulus 3 given by {..., −9, −6, −3, 0, 3, 6, 9,... }, {..., −8, −5, −2, 1, 4, 7, 10,... }, {· · · − 7, −4, −1, 2, 5, 8,... }. Every integer appears in exactly one of these residue classes modulo 3. A set with one element from each of the residue classes modulo m is called a complete residue system modulo m. An example of a complete residue system modulo m is given by 0, 1, 2, . . . , m − 1, called the system of least non-negative residues modulo m. Every integer is congruent to precisely one member of a complete residue system modulo m. (14) Prove that n2 + 1 is never divisible by 3 or by 7. (15) Show that there are no solutions to a2 − 3b2 = 8. (16) Suppose that a is odd. Prove that a2 ≡ 1 mod 8.

Division in a congruence

The rule governing division of congruences is more complicated. (17) Find numbers a, b, c, m such that ac ≡ bc mod m but where a is not congruent to b mod m. It is, however, true that ac ≡ bc mod m and (c, m) = 1 together imply that a ≡ b mod m (We use the notation (c, m) to denote the greatest common of c and m. The assertion (c, m) = 1 is often phrased ‘c and m are relatively prime’ or ‘c and m are coprime’.) We will always use the letter p to denote a (i.e. an element of the set {2, 3, 5, 7, 11, 13, 17, 19,... }. (18) Suppose that p does not divide a. Show that the numbers 0 · a, 1 · a, 2 · a, . . . (p − 1) · a are distinct modulo p. Explain why this implies that {0 · a, 1 · a, . . . , (p − 1) · a} is a complete residue system mod p. (19) Suppose that p does not divide a. Show that there is a solution x to the congruence ax ≡ 1 mod p. (20) Experiment with powers of numbers modulo a prime. Make and prove some conjec- tures related to your experiments. 3

Fermat’s Little Theorem

Fermat’s Little Theorem states that ap−1 ≡ 1 mod p for every prime p and every a coprime to p. (21) Calculate 290 mod 91. Explain why this proves that 91 is not prime. A number n which is not prime is called a to the base 2 if 2n−1 ≡ 1 mod n. (22) Show that 341 is a pseudoprime to the base 2. to the base a for any a > 2 can be defined analogously. A number n which is a pseudoprime to every base coprime to n is called an absolute pseudoprime or a . (23) Show that 561 is a Carmichael number. (24) Show that if 6m + 1, 12m + 1 and 18m + 1 are all primes then n = (6m + 1)(12m + 1)(18m + 1) is a Carmichael number. It was recently proved by Alford, Granville, and Pomerance that there exist infinitely many Carmichael numbers.

Squares

(25) Show that for exactly 1/2 of the numbers a in the set {1, 2, . . . , p − 1} there is a solution to x2 ≡ a mod p. (26) Experiment with sums of 2 squares, i.e. numbers n that can be expressed as n = a2 + b2. Make a conjecture about which p can be so expressed. Can you prove part of your conjecture? (27) For which primes p is there a solution to x2 ≡ −1 mod p? (28) For which primes p is there a solution to x2 ≡ 2 mod p? (29) We will call a ‘square’ mod p if x2 ≡ a mod p has a solution, and if there is no such solution we will call a ‘non-square’ mod p. Show that the product of two squares mod p is a square mod p and the product of a square and a non-square mod p is a non-square mod p. What about the product of 2 non-squares mod p? (30) Make a conjecture about which primes can be expressed as a2 + 2b2. Which primes can be expressed as a2 + 3b2? What about a2 + 5b2?

Chinese Remainder Theorem

Theorem Suppose that m1, m2, . . . , mk are pairwise relatively prime. Then for any numbers a1, a2, . . . , ak the system 4

x1 ≡ a1 mod m1

x2 ≡ a2 mod m2 (1) ...

xk ≡ ak mod mk has a unique solution mod m1m2 . . . mk. (31) I have a number of eggs in a basket. If I lay them out in rows of 3 there are 2 left over; if I lay them out in rows of 4 there is 1 left over; if I lay them out in rows of 5 there are 3 left over. How many eggs are in my basket?

Two multiplicative functions

 n  Let p be 0 if p | n, be 1 if n is a square mod p and be -1 if n is not a square mod p. Show  n  that for any p, sp(n) = p is a multiplicative function of n.

Let f(x) be a polynomial with integer coefficients. Let rf (n) be the number of solutions of f(x) ≡ 0 mod n.

Show that rf (n) is a multiplicative function of n. Miscellaneous Problems

(32) Prove that 103n+1 cannot be represented as the sum of two cubes of integers. (33) The last digit of the square of a is 6. Prove that the second to last digit is 3. (34) Is it possible to write a perfect square using only the digits 2,3,6 exactly 10 times each? (35) Can the sum of the digits of a perfect square add up to 1970? (36) Show that n2 + 3n + 5 is never divisible by 121 for any positive integer n. In the study of Fermat’s Last Theorem, Wieferich proved the following that if 2p is not congruent to 1 mod p2, then xp + yp = zp has no solutions with x, y, and z all coprime to p. (37) Show that 21092 ≡ 1 mod 10932. It is also known that p = 3511 has the same property and that there are no other primes smaller than 3 · 109 with this property. (38) Experiment with (p − 1)! mod p. Make a conjecture. Now prove your conjecture. (39) ∗ Suppose that a is both a square and a mod p. Must a also be a sixth power mod p? (40) ∗ Show that 2p + 1 cannot be a pseudoprime to the base 2. ∗ p (41) Prove that if P is a prime divisor of the Mersenne number Mp = 2 − 1 then P ≡ 1 mod p. (42) ∗∗∗∗ Show that if p ≡ 1 mod 3 then the congruence x3 ≡ 2 mod p can be solved if and only if p can be expressed as c2 + 27d2 for some c and d.