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)$.


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$.


Yeah, sure. There is one class per genus with discriminant $-96.$ That is, $24$ is one of Euler's convenient numbers, often called idoneal; see pages 36 and 59-63 in COX

Discr  -96 = 2^5 * 3  class  number  4

 all  
      96:  < 1, 0, 24>    Square        96:  < 1, 0, 24>
      96:  < 3, 0, 8>    Square        96:  < 1, 0, 24>
      96:  < 4, 4, 7>    Square        96:  < 1, 0, 24>
      96:  < 5, 2, 5>    Square        96:  < 1, 0, 24>

 squares  
      96:  < 1, 0, 24>

Once $p \equiv 1 \pmod {24},$ we have $(-6|p) = 1$ and $(-96|p) = 1.$ One of the four forms above integrally represents $p,$ and that must be the first in order to get $1 \pmod 8.$ Here are the first few primes represented, ignore the initial $1.$

jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./primego
Input three coefficients a b c for positive f(x,y)= a x^2 + b x y + c y^2 
1 0 24
Discriminant  -96

Modulus for arithmetic progressions? 
96
Maximum number represented? 
2000

      1,     73,     97,    193,    241,    313,    337,    409,    433,    457,
    577,    601,    673,    769,    937,   1009,   1033,   1129,   1153,   1201,
   1249,   1297,   1321,   1489,   1609,   1657,   1753,   1777,   1801,   1873,
   1993,