Summary
Today we started our search for those integers which do have a primitive root. We began by considering the case of a prime number p. The main tool we used was an analysis of the properties of polynomials mod p, particularly the number of roots that a given polynomial can have. By counting roots in this way, we were able to conclude that every prime number has a primitive root.
Counting Polynomial Solutions
We're used to thinking about polynomials whose coefficients are integers (or, more generally, real numbers). In this case, we have a result that tells us that a polynomial of a given degree doesn't have too many roots.
Fundamental Theorem of Algebra: A polynomial of degree n with real coefficients has exactly n complex solutions, and therefore at most n real solutions.
If we consider polynomials mod a given integer, though, this kind of result might not still hold.
Example
Consider the polynomial
. How many solutions does it have mod 65? Well, a solution to

forces a solutions to
(2)
We know that the first equation has solutions
, and the latter has solutions
. We can stitch these solutions together to give solutions to the original equation (1). The different choices of solutions mod 5 and 13 will in fact produce 4 solutions to this equation! This is quite different from what we're used to: we've shown that this degree 2 polynomial has at least 4 solutions. 
Though we might get more solutions to a given polynomial for a general modulus m, the situation for a prime modulus p is more in line with what we're used to.
Lagrange's Theorem: Let p be prime and let
be a polynomial of degreewith integer coefficients so that not every coefficient is divisible by p. Then
has at most n distinct solutions mod p.
Proof: We'll prove the result by induction. In the case that
, we're looking to count the roots of a linear polynomial
. Now if
then we get
, and so the linear congruence

has exactly one solution. In the case
, then, we've established what we wanted to prove. If, on the other hand, we have
then we can conclude that
(since not all the coefficients are allowed to be divisible by p). In this case we get

So the polynomial is a non-zero constant function, and hence has no solutions. In this case, then, we again have that the linear polynomial has no more than 1 solution mod p.
So suppose that we know the result for polynomials of degree n, and let
be a polynomial of degree n+1 where not every coefficient of f is divisible by p. If f has no roots mod p then we're done. Otherwise, suppose that a is a solution. Dividing the polynomial
by
then gives

where r is a polynomial of degree 0 (i.e., r is just an integer) and
is a polynomial of degree n. Notice that not every coefficient of q can be divisible by p, since this would force every coefficient of f to be divisible by p — something we know doesn't hold. Returning to the equation above, since a is a root of f mod p we must have

and so
. Hence we get

Now if b is any solution to
then we have
, meaning that
. By Euclid's Lemma we conclude that
or
. In the first case we have
, and in the second we get that b is a root of
mod p. So we see that any root of f is either a root of
or a root of
, so that

Since
is a polynomial of degree n which doesn't have all its coefficients divisible by p, there are at most n roots of
mod p. Equation (8) then says that there are at most n+1 solutions to
mod p. 
Though this result gives an upper bound on the number of solutions a particular polynomial can have mod p, for certain special polynomials this is enough to count solutions exactly.
Lemma: For
, the polynomial
has exactly d roots mod p.
Proof:
Fermat's Little Theorem says that
whenever
. This means that the polynomial
has
distinct solutions mod p.
Now if
then we get
for some integer e. Hence we can factor the polynomial
has

Now the polynomial on the left hand side has exactly p-1 roots. By Lagrange's theorem, the first polynomial in the factorization on the right hand side has at most d roots, and the second polynomial on the right hand side has at most
roots.

Now if
has fewer than d distinct solutions, this means that the right side has at most
solutions — contrary to the fact that we know it ahs
solutions because it's equal to the right-hand side of the equation. We conclude, then, that
has d distinct solutions, as desired. 
The benefit of the previous theorem is that it provides a means for calculating precisely how many elements of a given order exists mod p.
Counting Elements of a Given Order
Theorem: If
, then there are precisely
elements of order d mod p.
Proof: For a given divisor d, let
be the number of elements of order d mod p. The previous theorem tells us that there are d solutions to
. Therefore we have

But notice that if
then we get
This in turn tells us that
. Hence any element
in the set above must be an element of order c, where c is a divisor of c. Hence we have

By counting the number of elements on the left- and right-hand sides, we get
(13)
On the other hand, we saw long ago that
(14)
Hence we can combine (13) and (14) to give
(15)
Translated into convolutions, this says
. Convolving by
then gives


As a consequence of this result, we see that primitive roots exist for any prime modulus.
Corollary: For any prime p, there are exactly
many primitive roots.
Proof: Take
in the above result, and remember that a primitive root mod p is an element of order
. 







with integer coefficients so that not every coefficient is divisible by p. Then
elements of order d mod p.
many primitive roots.