TITLE: If $p=a^2+4b^2$ for some $a,b \in \mathbb{Z}$, then $a$ is quadratic residu modulo $p$?
QUESTION [7 upvotes]: If $p=a^2+4b^2$ for some $a,b \in \mathbb{Z}$ and $p$ prime, then $a$ is quadratic residu modulo $p$?
Approach: I thought it was true. (I could't find a counterexample). So I tried to prove it. I deduced that $a$ is a quadratic residu modulo $p$ iff $b$ is. Second I deduced that $p\equiv 1 \mod 4$ and that $a$ is odd. Can someone give me a hint on how to finish the proof? Thanks.

REPLY [8 votes]: We easily see that $p\equiv1\pmod4$, so for any prime factor $q\mid a$ we have, by quadratic reciprocity
$$
\left(\frac pq\right)=\left(\frac qp\right).
$$
OTOH we have $a^2=p-4b^2$. Therefore
$$
p\equiv 4b^2=(2b)^2\pmod q
$$
and $\left(\dfrac pq\right)=1$ for all those primes $q$.
So all the prime factors of $a$ are QRs modulo $p$. Therefore so is $a$.