Summary
Today we're finishing up our discussion of Fermat's Little Theorem. By the end of the class we'll state and prove a generalization which works for all integers — not just primes.
A Test for Primality
At the end of last class period we showed that $2^{90} \not\equiv 1 \mod{91}$. Now if 91 were a prime, then since
we would have gotten $2^{90} \equiv 1 \mod{91}$ by flt. Since we don't get this congruence, we must conclude that 91 is not prime. What's great about this result is that we have given a proof that 91 is composite without actually producing a factorization! This is HUGE, because it means we have a way to test for primality that doesn't involve the (usually quite difficult) problem of factorization.
We'll record this result in the following
Corollary: If n is an integer and you can find another integer a so that
and
, then n is not prime.
You should be careful not to think that this theorem is a perfect test for primality, as there are numbers which obey an flt-like congruence. That is to say, there are composite numbers n for which there exists integers a that satisfy
. In the case that a can be taken as 2, these integers get a special name.
Definition: A composite number is called a psuedoprime if
.
Example: 645 is psuedoprime
We'll show that
is a pseudoprime. To do this, we need to show that
. Now we could do this using successive squaring, but since we know the factorization of 645 we could instead verify that the following congruences all hold

Why is this the same thing as checking
, you ask? Our good old friend the CRT.
Ok, let's check these congruences. First, we know that
using flt, and so we have

Likewise we know that
by flt, and so

Finally, since
by flt, we have

Using successive squaring, we checked that
as desired. 
There are other composite numbers which are a kind of "strong" psuedoprimes, in the sense that they satisfy the conditions of psuedoprime numbers but with 2 replaced by an arbitrary a with
.
Definition: A Carmichael number is a composite number n such that every integer a with
satisfies
.
Example: 561 is Carmichael
In class we showed that
is Carmichael. To do this, we showed that for an arbitrary integer a with
, the congruences

are satisfied. To do this, notice first that since
we must also have
. This has to be the case since any common divisor of a with any of 3,7 of 17 would mean that a has a common divisor with 561, something we already know doesn't exist. Because a is relatively prime to all these prime numbers, then, we can apply flt in each case, as follows:


Notice that this same technique can be used to show that a number
such that [{$p_i-1 \mid n-1$]] for every i is a Carmichael number.
Euler's Theorem
We're now going to try to generalize Fermat's Little Theorem so that it can be applied to more than just prime numbers. We first noted that we will never have a chance of having an equation of the form
unless
. Hence to get some evidence for what this magical exponent might look like, we tried out a few values of n. We came up with the following
| n | ![]() |
Magic Exponent |
|---|---|---|
| 6 | ![]() |
2 |
| 8 | ![]() |
2 |
| 10 | ![]() |
4 |
| 12 | ![]() |
2 |
| 15 | ![]() |
4 |
We saw a lot of patterns here, but the trend which winds up providing a generalization of flt is to notice that the "magic exponent" is always a divisor of the number of integers between 1 and n which are relatively prime to n. This observation gives us a definition and a theorem.
Euler's
function: For an integer n,
is the number of integers between 1 and n (inclusive) which are relatively prime to n. This is also called Euler's Totient function.
Euler's Theorem: For any integer n and any a satisfying
, one has
.
Proof: To prove this theorem, let
be the set of least non-negative residues which are relatively prime to n. For the given a, we'll denote by
the set
. We claim that S and T are the same modulo n. If this claim is true, notice that this means that the product of the elements in S is the same as the product of the elements in T — at least modulo n. Hence we'd have

Expressed as a divisibility statement, this says
(8)
Since each of the
are relatively prime to n this means that
is also relatively prime to $n$, and hence the divisibility above implies that
; in other words, we have
.
Hence all that's left is to verify the claim. To do this, we'll show that each of the elements of T is relatively prime to n, and that each of them is distinct from each other modulo n. For the first, notice that since both a and
are relatively prime to n, their product is also relatively prime to n. Hence — modulo n — the elements of T are a subset of the elements of S. To show they're the same set, we'll show that T has
distinct elements, meaning that we need to show that
only when
. So suppose that
. Since
we can "cancel" the a's on both side of the equation, and so we have
. Of course this can only happen when
, so we're done. 






and
, then n is not prime.
.
.





function: For an integer n,
.