When all Dirichlet characters are real?

Consider $G$ is a group of all Dirichlet characters modulo $m$.

Problem. For what $m$ every character $\chi$ from $G$ is real?

Thoughts.

1. Let's expand $G = H_1 \times \dots \times H_k$, where each $H_k$ is cyclic. If $|H_i| > 2$ for some $i \in \{1,\dots,k\}$ then there is a character $\chi \in G$ that is not real.

2. Then question become about expansion of $\varphi(m)$. Since $\varphi(m) = \varphi(p_1^{i_1})\cdots\varphi(p_s^{i_s}) = p_1^{i_1-1}(p_1 - 1) \cdots p_s^{i_s-1}(p_s - 1)$ then we can say that $m = 2^l \cdot p_1 \cdots p_s$. From here somehow we have to understand the cyclic structure of $G$ and I don't know how to do it.

• Hint: If $p \ne 2$ is prime, then the group of Dirichlet characters modulo $p$ always contains at least one non-real character (because the group of units mod $p$ is cyclic of order $p-1$ and there are non-real $(p-1)$-st roots of unity). Can you see why this implies that your $m$ must be a power of 2? – David Loeffler Oct 28 '14 at 17:15
• @DavidLoeffler this is false. Assume for instance $p = 3$. – Jihad Oct 28 '14 at 17:33
• Oops, too early in the morning! But this works if $p$ is not either 2 or 3. – David Loeffler Oct 28 '14 at 17:36