TITLE: Primes of form $a^2 + 24b^2$
QUESTION [10 upvotes]: For a prime number $p \neq 2$, $3$, is it necessarily the case the prime number can be written in the form $a^2 + 24b^2$ if and only if $p \equiv 1 \text{ mod }24$?
I think this has to be true based upon the facts that $73 = 7^2 + 24(1^2)$, $241 = 5^2 + 24(3^2)$.

REPLY [11 votes]: If $p = a^2+24b^2$, then since $a^2\equiv 1\pmod{24}$ for all $a$ prime to $2,3$, it follows that $p\equiv 1\pmod{24}$.
Now suppose that $p\equiv 1 \pmod {24}$. Let $K=\mathbb Q(\sqrt{-6})$. The ring $R:=\mathbb Z[\sqrt{-24}]=\mathbb Z[2\sqrt{-6}]$ is a subring of $\mathcal O_K = \mathbb Z[\sqrt{-6}]$. The norm of an element $a+b\sqrt{-24}\in R$ is $a^2+24b^2$. Therefore, we would like to find out which rational primes are norms of elements of $R$.
Suppose that $p$ can be written as $p=a^2+6c^2$. Working modulo $24$, we find
$$1\equiv p \equiv1+6c^2\pmod {24}$$
so $c$ must be even. Hence, 

A prime $p\equiv 1\pmod{24}$ can be written as $p=a^2+24b^2$ if and only if it is a norm of an element of $\mathcal O_K$.

Equivalently,

A prime $p\equiv 1\pmod{24}$ can be written as $p=a^2+24b^2$ if and only if $p$ splits completely in $\mathcal O_K$ and the primes above $p$ in $\mathcal O_K$ are principal.

Here, things become a bit tricky because $\mathcal O_K$ is not a PID. To solve this completely (at least using this generalisable method), we need to use class field theory. We will use the following theorem:

Theorem: Let $H$ be the Hilbert class field (i.e. the maximal everywhere unramified extension) of $K$. Then a prime $\mathfrak p\subset \mathcal O_K$ splits completely in $H$ if and only if it is principal.

In other words, we can find out if a prime is principal by seeing whether it splits in $H$. Our problem reduces to

A prime $p\equiv 1\pmod{24}$ can be written as $p=a^2+24b^2$ if and only it splits completely in the Hilbert class field of $K$.

One can check that the Hilbert class field of $K$ is $\mathbb Q(\sqrt2,\sqrt{-3})$. A prime $p$ will split completely in this field if and only if it splits completely in $\mathbb Q(\sqrt2)$ and $\mathbb Q(\sqrt{-3})$. By the Kummer-Dedekind theorem, for $p\ne 2,3$, this occurs if and only if $X^2-2$ and $X^2+3$ both split mod $p$ - i.e. if and only if
$$\left(\frac2p\right)=\left(\frac{-3}p\right) = 1.$$
By quadratic reciprocity, this is equivalent to
$$\left(\frac 2p\right)=\left(\frac p3\right) = 1,$$
and this holds since $p\equiv 1\pmod 8$ and $p\equiv 1 \pmod 3$.