It’s been a while since we’ve added to the Newbie at Number Theory series. Even so, the series is not complete yet! There are a few gaping holes between what we have covered thus far and what I would like to cover before completing the series. Today we will be covering one of the missing topics: the concept of primitive roots. Knowing what they are, that they exist in the first place, and how to use them will make primitive roots an indispensable tool for us as number theorists.
We will begin with some observations meant to motivate the discovery of what we will eventually call primitive roots. Our goal is to ultimately prove that every prime has primitive roots. With this aim, we will first discover and prove results concerning the order of an integer modulo a prime. Finally, we prove a key theorem known as Lagrange’s Theorem (not the one from group theory!). This will then culminate in a proof that primes have primitive roots.
Let’s get into it!
Remark: Just to lay all the cards down, this article will assume that you are familiar with induction, modular arithmetic, Fermat’s Little Theorem, Euler’s totient function, and lastly, Gauss’s Theorem. All of which can be found in the Newbie at Number Theory series.
Outline of Awesomeness
Motivation
Let’s begin with an observation.
What’s your favorite small prime (greater than 2 to make it interesting)? Seven! Great choice. Let’s consider powers of the integers modulo 7.

Where the 1’s in the rightmost column are blue to indicate that all integers relatively prime to 7 when raised to the power are congruent to 1, by Fermat’s Little theorem.
A potentially interesting observation is that there are two numbers, and that run through all the residue classes modulo That is, is congruent to for some positive integer Likewise for

This is interesting because we know that we can get to all the integers: by starting with and then simply adding to itself:
In this manner, generates all the residue classes modulo any number using addition. What our observation about the numbers and modulo tells us is that they generate all the residue classes modulo using exponentiation (i.e., multiplication). For instance, take and raise it to multiple powers, and we get the same list of integers (after reducing modulo )
Although not in order.
Question: Do numbers like this always exist for prime numbers?
Let’s test some other small primes:

So, for at least some of the smallest prime numbers, there do exist these special numbers that run through all the residue classes. We call these numbers primitive roots of the prime
There is a `better way’ to look at primitive roots, and it introduces the notion of the order of a number modulo
Primitive Roots and the Order of a Number
The Order of a Number
Definition (Order of an Integer): Let be a prime. An integer has order if is the smallest positive integer such that
We denote the order of modulo by When the context is clear we will drop the subscript and write
Remark 1: Note, by Fermat’s Little Theorem, we know that when
Remark 2: We will be concerning ourselves here exclusively with numbers that are relatively prime to whatever prime we are working with. But to be complete, if then there is no power such that So, we say that has order infinity and write
Challenge: Can you prove that if and only if Give it a go!
Example (Working modulo 7): (Click in the Discovery)
Let’s continue to work modulo 7. Then, the order of the integers 1 through 6 are
Example (Working modulo 11): (Click in the Discovery)
Let’s try to work modulo 11. Then, the order of the integers 1 through 10 are
Order lets us succinctly define what a primitive root is.
Primitive Roots
Definition (Primitive Roots): Let be a prime. An integer with order modulo is called a primitive root of
For example, we would say and are primitive roots modulo since
Now it’s not a priori obvious why this definition jives with the property that we observed at the beginning. More precisely, we were working with the observation that runs through all the integers as we change Our definition only talks about one power of i.e., However, we will see in our next proposition that the two ideas are the same!
Proposition (Jiving Concepts): Let be a prime. Then, is a primitive root of if and only if run through the residue classes modulo I.e., run through the numbers but not necessarily in that order.
Example (Working modulo 7): (Click in the Discovery)
Recall that so that is a primitive root of by definition. Furthermore, by our observations at the beginning, we have
So that the powers of run through the integers modulo
Proof: (Click in the Discovery)
Let be a prime and note that
Forward: If is a primitive root of then run through the residue classes modulo
Let be a primitive root of Consider the powers We want to show they are all distinct modulo To do so, we proceed by contradiction. Suppose that for It follows, where However, this is a contradiction, since is a primitive root of and hence
Consequently, runs through the residue classes modulo
Backward: If run through the residue classes modulo then is a primitive root of
Let run through all the residue classes modulo We will show that Indeed, suppose that where If then contradicting that run trhough all the residuce classes modulo So,
Since it follows That is, for But, this contradicts that run trhough all the residuce classes modulo
Thus, is a primitive root of
Another Observation Regarding Orders
Question for you: What is the order of and modulo And, is either of them a primitive root of (Click in the Discovery)
So the order of is the smallest positive integer, such that Likewise, the order of is the smallest positive integer, such that
A `quick’ computation gives,

Thus, and which means that is a primitive root of
Did you notice anything about the previous examples given thus? Go take a look at what orders were present for different primes.
Well, when working modulo the only possible orders were and And, when working modulo the only orders were and Suspicious huh? It seems like the possible orders are the divisors of In fact, this is better stated as: It seems like the possible orders are the divisors of Where is Euler’s Totient function. In fact, this is indeed the case! We’ll see in just a moment why this happens, but it is worth remarking that this wonderful observation is just the tip of a deep result of group theory known as Lagrange’s theorem (group theory). Note: this is not Lagrange’s theorem we will see below; this is a different theorem from Lagrange that relates to group theory.
Proposition (Order Restrictions): Let be a prime. Then the order of any integer divides That is,
Proof: (Click in the Discovery)
Let be a prime, and Suppose that That is, for integers and such that (This is the division algorithm). By Fermat’s Little theorem, we know that Thus,
With some exponent algebra and that
Thus, contradicting that
We are now ready to show that every prime number has a primitive root!
All Primes Have Them!
The Proof- Step 1: Lagrange’s Theorem
This proof will end up with two theorems and two corollarys.
Theorem (Lagrange’s Theorem): Let be a prime and consider the polynomial
where and That is, the degree of equals Then, the congruence
has at most solutions modulo That is, incongruent solutions modulo
Remark: Note how this contrasts with the fundamental theorem of algebra, which states: Every polynomial of degree has exactly solutions, with multiplicity.
Proof: (Click in the Discovery)
Key Idea: What we want to do is use induction on the degree of the polynomial. To connect higher degree polynomials to lesser degree polynomials, we use polynomial long division (see here or here for a refresher on polynomial long division).
Beginning of Proof:
Base Case To begin, recall that we’ve shown that linear congruences such as have one unique solution modulo when see here. Thus, all we need to do is use and
Inductive Hypothesis: Now let’s assume that Lagrange’s theorem holds for all polynomials whose degree is equal to
Induction Step: Consider now the degree polynomial,
It’s possible that for all and thus has no solutions. In which case, we’re done! On the other hand, suppose has at least one solution, denoted Using polynomial division, we have
where is a degree polynomial and is an integer (this follows from the division algorithm for polynomials, see Remainder Theorem here). Let In particular, we have
We claim that Indeed, first observe But, so that as claimed.
In summary, thus far, we have
Now, we are in a perfect situation to use our induction hypothesis! We conclude that has at most solutions to the congruence Hence, has at most solutions since any solution of will also satisfy by the following observation:
Thus concluding the proof.
Now we need a stronger result for a very specific polynomial.
Corollary: Let be a prime. If then the congruence has exactly solutions.
Proof: (Click in the Discovery)
By Lagrange’s Theorem, we know that has at most solutions. Thus, all we must do is find all those solutions.
To begin, recall Fermat’s little theorem tells us that the congruence has exactly incongruent solutions. That is, are all solutions to
Let’s now factor into a particularly useful form for us. Using that we have for some Consequently, the following factorization falls out,
Observe that the polynomial has degree and has integer coeffients. Thus, by Lagrange’s theorem, has at most solutions. Furthermore, recall that we already concluded that the polynomial has at most solutions.
Now note that the only way that the congruence has exactly solutions is if has exactly solutions and has exactly soluions. Thus concluding our proof.
We are almost there! Woot!
Step 2 – Main Theorem
Theorem (Number of Integers with order ): Let be a prime and suppose that Then, there are exactly incongruent integers modulo that have order Where is Euler’s totient function.
Proof: (Click in the Discovery)
Let be a prime and suppose that Furthermore, let represent the number of incongruent integers, modulo there are that have order Thus, we want to show
To begin, by Proposition (Order Restrictions) above, every integer’s order must divide Consequently,
Where the sum is done over the divisors of See the footnote for an example.1
By Gauss’s Theorem (see the theorem here), we have
Recall that we are aiming to prove that To show this, we prove for all Which, by the equality above implies
Let
Case 1: The result follows
Case 2: Then, there is some whose order is Consider the following integers They are all distinct by Proposition (Jiving Concepts), and they satify since Furthermore, by the above corollary, they must be the only solutions to Thus, any integer with order must lie in the list In particular, has order when And there are integers such that (by definition of Euler’s Totient function). Thus proving the claim.
Thus, we are done! Since as a quick corollary, we have:
All Primes Have Them!
Corollary: All primes have primitive roots.
Proof: A primitive root of by definition, has order By the previous theorem, there are primitive roots of Let’s test this on the cases were and
Example (Working modulo 3, 5, and 7): (Click in the Discovery)
Recall the following tables:

Furthermore, we have and As our theorem asserts, there is one primitive root for and two primitive roots for and
Remark: Note how wonderful this result is. Not only do we know that all primes have primitive roots, but we also know how many they have, namely of them! This is quite remarkable! Better yet, we also know how many numbers will have any order whatsoever! For instance, let’s take How many numbers have order Well, zero since recall Proposition (Order Restrictions). What about how many numbers have order equal to The theorem tells us it should have And, checking the following list we made earlier,
We see that only has order
One more example: how many integers have order modulo First off, so we can use our main theorem which tells us there are of them. Checking our list,
we see that the four integers and have order
Question: Can we predict which numbers will have what orders?
Other than a few special cases, such as if and only if Or, if and only if there is no sure-fire way to know what numbers have what order. For instance, we have no idea if is a primitive root for an infinite number of primes or not! Maybe you will figure this out!
See you next time!
I hope that you had some fun today! I have always found primitive roots to be a very fun topic. Especially how useful they are when proving a result known as Euler’s Criterion for quadratic residues, which we will cover next time. Another utility of learning about primitive roots and orders is that this concept shows up again in group theory. When I later learned about generators and orders in group theory, I found that I had a much better intuition for them because of topics covered in this article. I hope this is true for you too!
As always, leave questions in the comments!
Be Kind. Be Curious. Be Compassionate. Be Creative.
And Have Fun!
Footnotes:
- Let Then, and are divisors of Thus, we have
Which, using what we’ve computed earlier, we see equals ↩︎

Leave a comment