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
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
is a solution. If you'd prefer a nonnegative solution, remember that since
we must have a unique solution to this equation modulo 35. Hence
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
. Since this is true, we know there is a unique solution modulo
. 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
for some integer a. Now we can substitute this expression in for x into the second congruence, and we have
— which is of course the same as
. Since
and
, 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
are solutions. Plugging these values back in for a in our initial expression for x —
— gives us
. 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 p is prime, then
.
We also started to prove the converse,
If n is composite, then
.
In our proof, we had shown that if n has a factorization into distinct factors, then
. 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
. But in fact, we know that these factors must be prime: if
and
for some
, then we get
, and we're back in the case where n can be factored into distinct factors. Hence we're left with the case
for some prime p.
Now in this case, if we happen to have a prime
, then we know that
. Hence we have

Hence when
for some prime bigger than 2, we know that
. The only remaining case to consider is when
. In this case, we can see that

Hence in all cases where n is composite, we have
.
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
, then
.
Example: The case 
Before proving flt, let's show that it holds in the case
. In other words, we'll show that
.
To do this, we need to compute a large power of 5. This can be done using "successive squaring":
(7)
Hence we have
(8)

The Proof of flt
With an example under our belt, we're now prepared to prove flt. So let a be given with
.
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
(which itself comes from the condition
) we get
if and only if
, and clearly two distinct elements
don't satisfy this condition. Moreover we know that every element of the second set is relatively prime to p: we could only have
if
or
, neither of which are possible. Hence the second set is a collection of
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
(10)
Now the left-hand side is just
(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

or, equivalently,
. 
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 p is prime and
, and if
, then
.
Proof: To see that this is true, notice that
means there is some
so that
. Hence we have


Example: Reducing Exponents
Suppose someone asked you to computer
. Now 11 is prime and
, so we know that
. hence we have

This is far easier to compute than the original problem (and I'll leave it to you to actually do the computation). 
Another useful corollary is
Corollary: If p is prime and
, then
is the multiplicative inverse of a modulo p.
Proof: Fermat's Little Theorem tells us that
. Hence
is a solution to the equation
, and so is the multiplicative inverse of a modulo p.
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
. We've already computed the successive squares of 5 modulo 23, and so we see that

So 14 is the inverse of 5 mod 23.
This will come in handy if we wanted to solve some kind of congruence like
— instead of using the Euclidean Algorithm to solve this problem, we could instead just multiply both sides by 13
. Hence our solution is just
(you can simplify this expression modulo 23 if you like). 
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
. To do this, we'll use successive squaring:

Hence we have
(16)
This might seem surprising, since if 91 is prime we should be getting
. So what went wrong? We'll talk about this in class on Friday.






.
.