# Summary

Today we started by introducing a few methods for solving simultaneous congruences suggested by students in the class. We then finished our proof of Wilson's Theorem before moving on to introduce and prove the "other" theorem of Fermat: Fermat's Little Theorem (aka, *flt*). We saw several applications and corollaries of this result which made some modular computations really quite simple.

# Revisiting CRT

We'll start by going back to the problem of solving simultaneous congruences. There were two new suggestions for solving these problems, and we'll provide a glimpse into both.

## Solving by Inspection

Sometimes you'll come across a system of congruences that looks something like this:

(1)How do you go about solving such a system? Well, the easiest way is to just look at the system and notice that $x = 1$ is a perfectly good solution, no matter what *m* and *n* are. You've just solved this system "by inspection."

A sneakier version of this same technique can be used to solve the following system

(2)While it might not seem that you can "see" a solution to this equally, notice that these equations are the same as

(3)Now we can see that $x = -3$ is a solution. If you'd prefer a nonnegative solution, remember that since $(5,7) = 1$ we must have a unique solution to this equation modulo 35. Hence $-3+35 = 32$ is another solution to this system (and happens to be the "least nonnegative" solution).

## Back Substitution

Suppose you're given the system

(4)and you want to find a solution. First, recall that our strong version of CRT says there's a solution if and only if $(12,14) \mid 10-6$. Since this is true, we know there is a unique solution modulo $[12,14] = 84$. That's all well and good, but how do we actually find such a solution?

First, notice that the first congruence is equivalent to saying $x = 6 + 12a$ for some integer *a*. Now we can substitute this expression in for *x* into the second congruence, and we have $6+12a \equiv 10 \mod{14}$ — which is of course the same as $12a \equiv 4 \mod{14}$. Since $(12,14) = 2$ and $2 \mid 4$, we know this system has 2 distinct solutions modulo 14. We could find these systematically (using the Euclidean Algorithm, etc.), but for the sake of time let's just notice that $a \equiv -2,5 \mod{14}$ are solutions. Plugging these values back in for *a* in our initial expression for *x* — $x = 6 + 12a$ — gives us $x = -18, 66$. You can check that both of these values for x solve the given congruences, and in fact at the same solution modulo 84 (as we'd expect!). Nice.

# Finishing off Wilson's Theorem

Last class period we proved

If

pis prime, then $(p-1)! \equiv -1 \mod{p}$.

We also started to prove the converse,

If

nis composite, then $(n-1)! \nequiv -1 \mod{n}$.

In our proof, we had shown that if *n* has a factorization into distinct factors, then $(n-1)! \equiv 0 \mod{n}$. To finish off the proof, then, we need to consider when *n* does not have a factorization into distinct factors. For this to be true, then we know that since both factors are the same, then $n = a^2$. But in fact, we know that these factors must be prime: if $n = a^2$ and $a = cd$ for some $1<c,d<a$, then we get $n = c(dcd)$, and we're back in the case where *n* can be factored into distinct factors. Hence we're left with the case $n = p^2$ for some prime *p*.

Now in this case, if we happen to have a prime $p>2$, then we know that $2p < p^2$. Hence we have

(5)Hence when $n = p^2$ for some prime bigger than 2, we know that $(n-1)! \nequiv -1 \mod{n}$. The only remaining case to consider is when $n = 2^2$. In this case, we can see that

(6)Hence in all cases where *n* is composite, we have $(n-1)! \nequiv -1 \mod{n}$.$\square$

# Fermat's Little Theorem

Wilson's Theorem is a neat little congruence identity to have around, but there's one which is actually much handier. This is one of the many number theoretic problems which Fermat worked on, and so it bears the name Fermat's Little Theorem (*flt*).

Fermat's Little Theorem: If $p \nmid a$, then $a^{p-1}\equiv 1 \mod{p}$.

#### Example: The case $a = 5, p = 23$

Before proving *flt*, let's show that it holds in the case $a = 5, p = 23$. In other words, we'll show that $5^{22} \equiv 1 \mod{23}$.

To do this, we need to compute a large power of 5. This can be done using "successive squaring":

(7)Hence we have

(8)$\square$

## The Proof of *flt*

With an example under our belt, we're now prepared to prove *flt*. So let *a* be given with $p \nmid a$.

We start by explaining why the sets

(9)are the same modulo *p*. For one, we notice that all the elements of the latter set are distinct: using the fact that $(a,p) = 1$ (which itself comes from the condition $p \nmid a$) we get $ia \equiv ja \mod{p}$ if and only if $i \equiv j \mod{p}$, and clearly two distinct elements $i,j \in \{1,2,\cdots,p-1\}$ don't satisfy this condition. Moreover we know that every element of the second set is relatively prime to *p*: we could only have $p \mid ij$ if $p \mid i$ or $p \mid a$, neither of which are possible. Hence the second set is a collection of $p-1$ distinct, nonzero elements modulo *p*, and hence must be the same (modulo p) as the first set.

With this equality of sets (modulo *p*) established, we now notice that the products of all elements in both sets must be the same

Now the left-hand side is just $(p-1)! \equiv -1 \mod{p}$ (using Wilson's Theorem), whereas the right hand side is just [{$a^{p-1}(p-1)! \equiv -a^{p-1} \mod{p}$]]. Hence we get

(11)or, equivalently, $a^{p-1} \equiv 1 \mod{p}$. $\square$

# Some Useful Corollaries

There are several nice things that can be taken away from *flt*. The first application let's us compute large exponentials very easily

Corollary: If

pis prime and $p \nmid a$, and if $b \equiv c \mod{p-1}$, then $a^b \equiv a^c \mod{p}$.

Proof: To see that this is true, notice that $b \equiv c \mod{p-1}$ means there is some $k \in \mathbb{Z}$ so that $b = c + (p-1)k$. Hence we have

(12)$\square$

#### Example: Reducing Exponents

Suppose someone asked you to computer $7^{147} \mod{11}$. Now 11 is prime and $11 \nmid 7$, so we know that $7^{10} \equiv 1 \mod{11}$. hence we have

(13)This is far easier to compute than the original problem (and I'll leave it to you to actually do the computation). $\square$

Another useful corollary is

Corollary: If

pis prime and $p \nmid a$, then $a^{p-2}$ is the multiplicative inverse ofamodulop.

Proof: Fermat's Little Theorem tells us that $a^{p-2}a \equiv 1 \mod{p}$. Hence $a^{p-2}$ is a solution to the equation $ax \equiv 1 \mod{p}$, and so is the multiplicative inverse of *a* modulo *p*.$\square$

#### Example: Computing an inverse using *flt*

Suppose you want to computer the inverse of 5 modulo 23. Then our previous corollary says this should be $5^{21}\mod{23}$. We've already computed the successive squares of 5 modulo 23, and so we see that

(14)So 14 is the inverse of 5 mod 23.

This will come in handy if we wanted to solve some kind of congruence like $5x \equiv 13 \mod{23}$ — instead of using the Euclidean Algorithm to solve this problem, we could instead just multiply both sides by 13 $x \equiv 14 \cdot 5 x \equiv 13 \cdot 14 \mod{23}$. Hence our solution is just $13 \cdot 14 \mod{23}$ (you can simplify this expression modulo 23 if you like). $\square$

# A Final Computation

We've covered a lot of stuff so far in class, so let's just do another computation to double-check our computational skills. We'll compute $2^{90} \mod{91}$. To do this, we'll use successive squaring:

(15)Hence we have

(16)This might seem surprising, since if 91 is prime we should be getting $2^{90} \equiv 1 \mod{91}$. So what went wrong? We'll talk about this in class on Friday.