The Chinese remainder theorem implies that $U(mn) \cong U(m) \oplus U(n)$ if $m,n$ are relatively prime: thus, we only need to understand prime powers. The general formula is:
- $U(2) = 1$
- $U(2^n) \cong \mathbb{Z} / 2 \mathbb{Z} \oplus \mathbb{Z} / 2^{n-2} \mathbb{Z}$
- $U(p^n) \cong \mathbb{Z} / (p-1) \mathbb{Z} \oplus \mathbb{Z} / p^{n-1} \mathbb{Z} \cong \mathbb{Z} / \varphi(p^n) \mathbb{Z}$.
For odd primes, we have $U(p^n)$ is a cyclic group of order $\varphi(p^n) = (p-1)p^{n-1}$. A neat way to show the subgroup of order $p^{n-1}$ is cyclic is inspired by $p$-adic analysis: if $x \equiv 1 \bmod p$, we can actually define the $p$-adic logarithm by its power series
$$ \log(x) = \sum_{i=1}^{+\infty} (-1)^{i+1} \frac{(x-1)^i}{i} $$
and this gives an explicit isomorphism between the subgroup of $U(p^n)$ of things equivalent to $1$ modulo $p$, and the additive group of elements of $\mathbb{Z} / p^n \mathbb{Z}$ of things equivalent to $0$ modulo $p$. The inverse is $\exp(x)$, again defined by the power series.
These power series make sense, because for sufficiently large $i$, all the terms become zero modulo $p^n$. The divisions by $p$ aren't a problem: if we lift to the integers, $(x-1)^i$ always has more factors of $p$ than $i$ does, so we still get a rational number that we can reduce modulo $p^n$. (some care is needed to show this is well-defined if $n \geq p$)
The powers of $2$ are, unfortunately, weird: we get $U(2^n) \cong \mathbb{Z} / 2 \mathbb{Z}\oplus \mathbb{Z} / 2^{n-2}\mathbb{Z} $ for $n \geq 2$. You can still define the logarithm and exponential as above, but you only get an isomorphism between the elements that are equivalent to $1$ modulo $4$ and the elements that are equivalent to $0$ modulo $4$.
The $\mathbb{Z} / 2\mathbb{Z}$ summand of $U(2^n)$ is simply the subgroup $\pm 1$: the projection onto this summand from $U(2^n)$ is obtained by simply sending $x$ to its residue modulo $4$.