Finding all integers $n$ such that $\left(\mathbb{Z}/n\mathbb{Z}\right)^\times$ has exponent $2$ This problem is from a past qualifying exam.
Definition
A group $G$ has exponent $e$ if $g^e=1$ for all $g\in G$.
Problem

Let $G=\left(\mathbb{Z}/n\mathbb{Z}\right)^\times$. Find all the integers $n$ for which $G$ has exponent $2$.

My work so far: Need to find $n$ such that $\overline{b}^2=\overline 1$ for $\overline{b} \in G$. So I need to find $n$ such that $n \mid (b^2-1)$ and $(b,n)=1$. Well, how do I now go about finding all the $n$'s. I tried a few examples like $n=1$ etc. But then I still have to deal with $b$. This kind of problem is new to me. Can somebody kindly show me what I've done wrong/right here?
May be suggest a way to go about finding these $n$'s.
Thank for your help.  
 A: A few helpful facts, that can be learned here:


*

*$(\mathbb{Z}/n\mathbb{Z})^{\times}=\prod(\mathbb{Z}/p_i^{k_i}\mathbb{Z})^{\times}$, where $n=\prod p_i^{k_i}$ is the prime factorization of $n$.

*$(\mathbb{Z}/2^k\mathbb{Z})^{\times}\cong \mathbb{Z}/2\mathbb{Z}\times\mathbb{Z}/2^{k-2}\mathbb{Z}$ for $k\ge 2$.

*$(\mathbb{Z}/p^k\mathbb{Z})^{\times}\cong\mathbb{Z}/p^{k-1}(p-1)\mathbb{Z}$ for odd primes $p$.


I believe this should be enough to answer your question.  I got values $n=3,4,6,8,12,$ and $24$, and nothing else.
If you don't want to rely on the complete strength of 2. and 3. above, you can reason as follows.  First, the element $3$ will have order greater than $2$ in the group $(\mathbb{Z}/2^k\mathbb{Z})^{\times}$ for $k\ge 4$, from which it follows that only $k=2$ and $k=3$ give groups with exponent $2$.  Also, the element $2$ will have order greater than $2$ in the group $(\mathbb{Z}/p^k\mathbb{Z})^{\times}$ for $p\ge 5$ and for $p=3$, $k\ge 2$, from which it follows that only $p=3$ and $k=1$ gives a group with exponent $2$.  Now put these results together with 1. to obtain the values of $n$ listed above.
