We will begin with a prime modulus p. Choose any a from 1 to p-1and consider the multiples
Here is the trick! Multiply all the numbers together and the result
must be the same as multiplying all the numbers from 1 to p-1.
Thus,
Fermat's Theorem: For any number a relatively prime to the prime p, we have
![]()
By this theorem, we can conclude immediately that
.
As a word of caution, it may turn out that a smaller
power will produce 1. For example, if a=9, then
.
So a smaller power of 9 is congruent to 1
mod 19.
For some further examples, you can appreciate Fermat's theorem by
checking
,
,
etc. It really is amazing.
It is a little unusual that the smallest power of 3 that is 1 mod 19
is the largest that can be under Fermat's theorem. Such a number is
called a primitive root modulo p. That is, a primitive root
a has the property that the smallest k for which
is p-1. A subtle and extremely important fact is that
every prime number p has some primitive root g. Then the
powers g0, g1, g2, ... , gp-2, cover every congruence
class from 1 to p-1.
Euler discovered the generalization of Fermat's theorem to an arbitrary modulus m. The trick is to consider only numbers a which are relatively prime to m. Then similar reasoning leads to:
Euler's Theorem: For any a relatively prime to m, we haveIn the case m=12, that would imply
![]()