# What does “maximum order elements to mod n” mean for a number n without primitive roots modulo n?

I apologize because probably this is trivial, but I do not understand the concept:

"maximum order elements to mod n for n".

This is the context: in the Wikipedia in the primitive roots modulo n page there is a table in the section "Table of primitive roots" (link) saying:

"The following is a list about maximum order elements to mod n for $n \le 36$,

And then the table also explains:

"maximum order elements to mod n (for ns with "*", the maximum order of n does not equal to the Euler totient function of n, so there are no primitive roots mod n, for other ns, they are primitive roots mod n)

Basically, I would like to understand the definition and how to calculate the maximum order elements to mod n for those numbers n that do not have primitive roots mod n.

For instance, according to the explanation in the Wikipedia, for $n=8$ the maximum order element to mod 8 are $\{3,5,7\}$, and $n=8$ does not have primitive roots modulo 8, but I do not understand how they are calculated.

UPDATE As far as I can see, it would be as follows, but if somebody could confirm this, it would be very appreciated, because I do not see it clearly:

For instance:

$3^1 = 3 \equiv 3 \pmod8$

$3^2 = 9 \equiv 1 \pmod8$

$3^3 = 27 \equiv 3 \pmod8$

$3^4 = 81 \equiv 1 \pmod8$

$3^5 = 243 \equiv 3 \pmod8$

$3^6 = 729 \equiv 1 \pmod8$

$3^7 = 2187 \equiv 3 \pmod8$

So in this case the length of the cycle of the mods is 2 (only 1,3 and the again 1,3, etc.) and that is smaller than the totien function $\varphi(8)=4 \gt 2$ so 3 is not a primitive root modulo 8. Is this correct?

If it is correct then the only way to calculate the "maximum order elements to mod n" for a number n without primitive roots modulo n is as above, making all the possible exponents and deciding according to the results. Is that right?

Thank you!

UPDATE: the explanation in the answers worked like a charm, here is the Python code (very brute force but works, be aware that the variable "value" is the value for n):

from gmpy2 import gcd
def first_max_order_elem_mod_n(value):
lo = []
for i in range (1,value):
if gcd(value,i)==1:
myexp = 1
while ((i**myexp)%value)!=1:
myexp = myexp + 1
lo.append([i,myexp])

bigger = 0
current_pos = 0
for k in lo:
if k[1]>bigger:
current_pos = k[0]
bigger = k[1]
return current_pos


In ${\mathbb{Z}/n}^{\times}$, look at the set of $k$, $1\le k \le n$, for which $(k,n) = 1$ (multiplicative units in $\mathbb{Z}/n$). Calculate their orders (the smallest positive integer $i$ s.t. $k^i = 1$). Denote by $o$ the largest $i$ you get from your order calculation for all units. Then the right table entry is $o$, the left those $k$ with order $o$. In your example case for $n=8$, for all units $k$ different from 1, $k^2 =1$ mod $n$; and the units other than 1 are $\{3,5,7\}$.

• That's correct, as long as you mean the first such i, which is its order (I'm sure you mean that). Note that if $x^i = 1$ mod n, then $x^{i+kn}= 1$ mod n for any integer k, also $x^{2i} = (x^i)^2 = 1^2= 1$; etc. – gnometorule May 18 '15 at 2:51
• yes I meant that. This was cool, thank you! – iadvd May 18 '15 at 2:57
• worked like a charm! added the Python code to the question, it could be helpful for other people! – iadvd May 18 '15 at 3:31
• @iadvd: I don't think so. I'm not familiar with one (off-hand), but that doesn't mean that there couldn't be one I don't know. :) – gnometorule May 21 '15 at 12:06
• got it! it is the maximum value of the Carmichael function, it was explained in the main answer of this other question: math.stackexchange.com/questions/1292429/… – iadvd May 22 '15 at 0:24

I think the important results are that the multiplicative group of $\mathbb Z_{p^{\alpha}}$ is $\mathbb Z_{p^{\alpha-1}}$ unless $p^{\alpha}$ is a power of $2$ larger than $4$ in this case the multiplicative group is $\mathbb Z_2 \times\mathbb Z_{p^{\alpha-2}}$.

In any case once you have this result, which can be proven using lifting the exponent lemma you can arrive to the following result using the chinese remainder theorem:

The multiplicative group of $n=p_1^{\alpha_1}p_2^{\alpha_2}\dots p_n^{\alpha_n}$ is equal to the direct product of the multiplicative groups of each of the prime powers.

From here you can see that the largest possible order an element can have is equal to the least common multiple of the orders of the cyclic groups that compose that direct product.

Calculating the elements of maximum order for $\mathbb Z_{2^n}$ with $n\geq 2$ is simple because $5$ and $-5$ are two generators for each of the two halves of the group.

However calculating the elements of maximum order of some groups can be messy. For example suppose we want to calculate the elements of maximum order of $\mathbb Z_{7\cdot19}$ The group of $\mathbb Z_{21}$ is $\mathbb Z_6\times \mathbb Z_18$ but if for example we take an element that is a generator $\bmod 19$ then this element is going to be of maximum order no matter what its congruence $\bmod 7$ is. So it is very messy in general.

• thank you for the theoretical explanation, I will need some extra readings to understand the lemma and theory of multiplicative groups, but it is really interesting. – iadvd May 18 '15 at 2:58