Addition and multiplication are 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
We typically 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\). This means that
Thus
Therefore, it is not divisible by 9.
Example 2
We do this by taking the alternating sum of the digits so \(4 - 3 + 2 - 1 = 2\). Thus, \(1234 \equiv 2 \mod 11\) and \(1234\) is not divisible by 11. This works because
But we know that
Therefore
Example 3
This means that we want to know if \(1234567 = a^2\) for some \(a\). Then, suppose \(b\) is the last digit of \(a\). If we take \(a\) module \(10\), then we will get exactly \(b\). Thus
We know \(b\) is a single digit. Then \(b\) can only be some number in \(\{0,1,2,3,4,5,6,7,8,9\}\). Thus, \(b^2\) can only be one of the following
But we’re working module \(10\), so the possible unique digits are \(\{0,1,4,9,6,5\}\). Thus, 7 is not in the set so \(123457\) is not a square.
Example 4
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
Cubes don’t work really well with module 8 but they work really well with module 9. Observe the following
Observe that adding \(3\) to \(a\) didn’t change its value module 9. In other words
So adding \(3\) keeps \(a\) in the same residue class module \(9\). So if \(a = 0\), then
And if \(a = 1\), then
And if \(a = 2\), then
So this means any cube can only leave a remainder of \(\{-1,0,1\}\). Therefore, any sum of three cubes will look like the following module \(9\)
So now we can just consider all possible sums. For example \(\{(-1-1+0),(-1+0+0), (-1+0+1), (1+1+0)\cdots\)}. In fact, it turns out that the possible sums of cubes can only leave a remainder of
This means that if \(n \equiv 4 \bmod 9\) or \(n \equiv 5 \bmod 9\), then we don’t have a solution. Only the remainders of \(4\) and \(5\) (module \(9\)) are not possible when writing \(n\) as a sum of three cubes. For example, if \(n = 39\), then \(39 \bmod 9 = 3\) so \(39\) can be written as a sum of three cubes. While \(n = 40\) leaves a remainder of \(40 \bmod 9 = 4\). Therefore, \(40\) can’t be written as a sum of three cubes.
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
It’s obviously not, but hypothetically suppose \(n=35\) has 1000 digits. Then, we can use Fermat’s theorem to say that If 35 is a prime, then the following
must be true. 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\) every iteration in order for the product not to 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}\). This is good but isn’t great since we 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
Thus
So it’s not \(2\). Therefore, \(35\) is not prime. So this is a much faster method. (I believe this is called Modular Exponentiation)
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. It is kind of a 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