Addition and multiplication is preserved module a fixed number so
Note that division is not preserved. Similarly \(a_1^{b_1} \not\equiv a_2^{b_2} \bmod c\)
Residue Classes
Based on the definition of congruence, we can define residue classes as follows
Example: for \(c=5\), the set of residue classes are \([0],[1],[2],[3],[4]\) and \([0] = [5] = [10] = \cdots\) since they all leave the same remainder modulo 5.
Both addition and multiplication are defined on congruence classes.
The set of residue classes form a ring.
Example 1
Suppose we want to test if \(357\) is divisible by 9. We do this by summing the digits \(3+5+7 = 15\) and then again \(1+5 = 6\). From this we conclude that \(357 \equiv 6 \bmod 9\). Why does this work? because
We know that \(10 \equiv 1 \bmod 9\). So we can re-write the above as
Example 2
Suppose we want to test if \(1234\) is divisible by 11. Then what we do is that we take the alternating sum of the digits so \(4 - 3 + 2 - 1 = 2\) so \(1234 \equiv 2 \mod 11\). This works because
We note that \(10 \equiv -1 \bmod 11\) so
Example 3
Suppose we want to know if \(1234567\) is a square. So we want to know if \(1234567 = a^2\) for some \(a\). Then, suppose \(b\) is the last digit of \(a\). Then
The possibilities for \(b\) are \(0,1,2,3,4,5,6,7,8,9\). So \(b^2\) is
Therefore, the last digit is \(0,1,4,9,6,5\). Thus, 7 is not in the set so \(123457\) is not a square.
Example 4
What is \(a^2 \bmod 8\). If we take \(a\) module 8, then the possible distinct digits are \(0, 1,2,3,4,5,6,7\). So now if we take \(a^2\) module 8, we get
An an application of this, we can ask: can we write integers as sums of three squares so \(a^2 + b^2 + c^2\)? The answer is no because we can’t write
Since if \(a \equiv 7 \bmod 8\), then \(a^2 + b^2 + c^2\) is the sum of integers from the set \(\{0,1,4\}\) only. Note here that we chose squares module 8, because when doing so, we had a very restricted list of \(\{0,1,4\}\). Hence, it is useful to apply module 8 on squares.
Example 5
This time let’s consider cubes. Can we write any integer \(n\) as a sum of three cubes so
Cubes don’t work really well with module 8 but they work really well with module 9. Observe the following
So adding 3 to \(a\) didn’t change its value module 9. So we only need to consider the set \(\{-1,0,1\}\) because we can construct any number by adding a multiple 3 to a number of the set. For example \(4 = (1 + 3)\), \(6 = (0 + 3(2))\) and so on. Therefore,
The possible sums are
So if \(n \equiv 4 \bmod 9\) or \(n \equiv 4 \bmod 9\), then \(n \neq a^3 + b^3 + c^3\). Note here that \(-3 \equiv 6 \bmod 9\) and \(-1 \equiv 8 \bmod 9\). So it’s possible to write \(6\) or \(8\) as sums of three cubes. Only remainders of 4 and 5 (module 9) are not possible.
Fermat's Theorem
An application of this theorem, suppose we want to show that the following is an integer
So multiply by 15
And now, we want to show that this is divisible by 3 and 5 so it’s divisible by 15. To check divisibility by 3, by Fermat’s \(n \equiv n^3 \bmod 3\). Therefore,
Clearly this is divisible by 3. For 5, again by Fermat’s \(n \equiv n^5 \mod 5\)
Clearly this is also divisible by 5. Therefore, \(3n^5 + 5n^3 + 7n\) is divisible by 15 and we are done.
Fermat's Proof
Recall from the previous lecture that \(\binom{p}{k}\) is divisible \(p\) if \(1 \leq k \leq p-1\). This resulted having
So now we prove Fermat’s theorem by induction on \(n\). Note that
So now, for the inductive case, suppose that \(n^p \equiv n \bmod p\).
We can do the same thing for negative integers.
Application of Fermat's Theorem
Is \(n=35\) a prime? It’s obviously not but suppose \(n\) has 1000 digits. So now we can use Fermat’s theorem to say “If 35 is a prime, then
if this isn’t true, then 35 is definitely not a prime. (What if this was true, does that immediately imply that 35 is prime? no, we’ll discuss later). So now how do we calculate \(2^35\)? we can do this by reducing the product modulo 35 each step so the product doesn’t get too big. We can start with \(2^6 = 64\) and then keep reducing as follows
We can keep doing this until we reach \(2^35\) or the 1000 digits number. This is good but isn’t great since we still have to do this for 35 steps until we reach \(2^{35}\). Instead write \(35\) as powers of 2 so
and now we will square 2 in every step as follows
Now
So it’s 2 and therefore, \(35\) is not prime. So this is a much faster method.
Now, if \(n\) passes the test, It isn’t a guarantee that \(n\) is prime. What we might do is test if \(3^n \equiv 3 \bmod n\). If it still passes, you’ll suspect it is a prime but it’s not a guarantee. Kind of probabilistic test at this point. So with some probability, this \(n\) is a prime.
Infinitely Many Primes of the Form \(4n+1\)
Recall from the primes lecture that to prove that we have infinitely many primes of the form \(4n+1\), we used the fact that if a prime divides \(n^2 + 1\), then \(p = 2\) or \(p = 4n+1\) but we never proved this fact. To show, first notice these values for the first \(n\) integers again
\(n\) | \(1\) | \(2\) | \(3\) | \(4\) | \(5\) | \(6\) | \(7\) | \(8\) |
\(n^2+1\) | \(2\) | \(5\) | \(10\) | \(17\) | \(26\) | \(37\) | \(50\) | \(65\) |
Prime Factors | \(2\) | \(5\) | \(2,5\) | \(17\) | \(2,13\) | \(37\) | \(2,5\) | \(5,13\) |
Observe that all of these prime factors are either 2 or 1 module 4.
Suppose now that \(p\) is an odd prime and it divides \(n^2 + 1\). This means that \(n^2 \equiv -1 \bmod p\). Then we can use Fermat’s theorem to show that \(p\) satisfies \(p \equiv 1 \bmod 4\). So
So \((-1)^{(p-1)/2}\) is \(-1\) if \((p-1)/2\) is odd and 1 if \((p-1)/2\) is even. Therefore, we must have \((p-1)/2\) be even. This means that