for every prime $p>7$, there are integers $x,y$ such that $p=x^2+7y^2$, if and only if, $p \equiv 1,2,4 \pmod7$. I'd really love your help with showing that for every prime $p>7$, there are integers $x,y$ such that $p=x^2+7y^2$, if and only if, $p \equiv 1,2,4 \pmod7$.
$x^2+7y^2$ is the norm of the Euclidean domain $a+b\sqrt{-7}$ and $p$ is composite in the domain iff it is a norm, i.e $x^2+7y^2=1$ (I'm not sure I need this now).
as well the squares$\pmod7$ (The numbers that left the same residue after squaring)  are $0,1$ so I guess $x^2+y^2 \equiv 0,1,2 \pmod7$, Is this correct? How should I go on?
Thanks a lot!
 A: Here is a standard algebraic number theory approach; I don't know if it is at the right level for the OP.


*

*$\mathbb Z[(1 +\sqrt{-7})/2]$ is a PID (well-known, and easily checked e.g. by the Minkowski bound).

*A prime $p \neq 7$ splits in this ring iff $p$ is a square mod $7$.  (Quadratic reciprocity.)

*This gives the result, except that one gets $p = x^2 + 7 y^2$ where $x$ and $y$ might be half-integers rather than integers.  But multiplying both sides by $4$ and  looking mod $8$ rules this latter possibility out (as long as $p \neq 2$).  
A: You can refer to this part of Granville's course notes. In particular from Proposition 4.1: An integer $n$ is properly represented by a binary quadratic form of discriminant $-7$ iff $-7$ is a square modulo $4n$. Since $-7\equiv 1\pmod 4$ and $\left(\frac{-7}{p}\right)=\left(\frac{p}{7}\right)$ for all primes $p$, $-7$ is a square mod $4p$ if $p\equiv 1,2,4 \pmod 7$.
There's only one reduced binary form with discriminant $-7$ (an exercise in the notes), so all such primes can be written as $x^2+xy+2y^2$. If $x$ is even or $x$ and $y$ are both odd, then this represents an even number, so we must have $y=2z$ for some integer $z$.
So there are $x,z\in\mathbb{Z}$ with 
$
p=x^2+2xz+8z^2=(x+z)^2+7z^2
$.
