Group $U(n)$ closed under modular multiplication with every element is its own inverse With,
$$U(n) = \lbrace k : (k, n) = 1 \space and \space 0 < k < n \rbrace.$$
For some $n$, each element of $U(n)$ will have itself as its own multiplicative inverse. As an example, for $n = 8$:
$$U(8) = \lbrace 1, 3, 5, 7 \rbrace$$
Inverse of $1, 3, 5, 7$ under multiplication modulo $8$ is respectively $1, 3, 5, 7$. And it is very weird, because in this case multiplication of $a$ with $b$ is same as division of $a$ with $b$.
My question is are there infinitely many $n$ such that $U(n)$ satisfies the property above? I wrote a script and tested this for all $n \lt 1000$ and found only the following solutions:
$$n = 1, 2, 3, 4, 6, 8, 12, 24$$
Are there any more solutions, or are they the only ones? How to show that?
 A: Let $n = p_1^{\nu_1} \cdot \dots p_r^{\nu_r}$ be the prime decomposition of $n$. Then we get $\mathbb{Z}/n\mathbb{Z}^{\times} \cong \mathbb{Z}/p_1^{\nu_1}\mathbb{Z}^{\times} \times \dots \times \mathbb{Z}/p_r^{\nu_r}\mathbb{Z}^{\times}$ and for prime powers we have 
$\mathbb{Z}/p^{\nu}\mathbb{Z}^{\times} \cong \begin{cases}
               C_1               & p = 2 \;\text{and}\; \nu = 1\\
               C_2 \times C_{2^{\nu -2}}               & p = 2 \;\text{and}\; \nu \geq 2\\
               C_{\varphi({p^\nu})} = C_{p^{\nu - 1}(p - 1)} & \text{otherwise}
           \end{cases}.$
This gives you the groups $U(n)$. Now one can show that a finite  group such that every non-trivial element has order $2$ is a product of copies of $C_2$. Can you answer your question now?
A: You are asking for $k^2\equiv1\pmod n$ for all $k$ such that $(k,n)=1$.
Using any prime $p$ for $k$, this means either $n|p^2-1$ or $p|n$.
In particular,  either $n|5^2-1=24$ or $5|n$.
If $5|n$ then $n$ does not divide $p^2-1$ for any $p\equiv2$ or $3\pmod5$, 
so $p|n$ for all such $p$, which is absurd.
