$
\newcommand{\ZZ}{\Bbb Z}
\newcommand{\ZZn}[1]{\ZZ / {#1} \ZZ}
$

One of the most familiar rings is the ring of integers modulo $n$, often denoted $\ZZn{n}$. Like all rings, it has an additive structure and a multiplicative one. The additive structure is straightforward: $\ZZn{n}$ is cyclic, generated by $1$. In fact, every integer $a$ coprime to $n$ is a generator for this group, giving a total of $\phi(n)$ generators. The multiplicative structure, on the other hand, is far less apparent.

Not all elements of $\ZZn{n}$ can participate in the multiplicative group, because not all of them have inverses. For example, 4 has no inverse in $\ZZn{6}$; there’s no integer $a$ such that $4a \equiv 1 \pmod 6$. Elements that do have inverses are called *units*, and we’ll denote the group of units in $\ZZn{n}$ as $U_n$.

Since an element $a \in \ZZn{n}$ is a unit iff $a$ and $n$ are coprime, there are $\phi(n)$ units, where $\phi$ is the totient function. But the size of the group alone doesn’t nail down the group structure.

For example:

- $U_5 = \{ 1, 2, 3, 4 \}$:
- generated by $2$: $2^0 = 1$, $2^1 = 2$, $2^2 = 4$, $2^3 = 8 = 3$
- also generated by $3$: $3^0 = 1$, $3^1 = 3$, $3^2 = 4$, $3^3 = 2$
- this group is isomorphic to $\ZZn{4}$

- $U_8 = \{ 1, 3, 5, 7 \}$
- every element squares to $1$
- this group is isomorphic to $\ZZn{2} \times \ZZn{2}$

Is there a way to find the structure of $U_n$?