TITLE: No integers satisfying $x^2+2y^2 = p$
QUESTION [5 upvotes]: Suppose $p$ is a prime such that $p \equiv 5,7\ (\text{mod}\ 8)$ then I want to show that there exist no integral solutions $(x,y)$ such that $x^2+2y^2 = p$.
My idea was to look at the equation modulo $2$. We get $x^2 \equiv 1 (\text{mod}\ 2)$. But this has solutions for $x \in \mathbb{Z}$.
Then what am I missing? or is the statement false?

REPLY [3 votes]: Another approach is simply to compute $x^2+2y^2 \bmod 8$ for $x,y =0, \dots 7$. The result is $0, 1, 2, 3, 4, 6$. Therefore, if $z \equiv 5,7 \bmod 8$, then $z$ is not of the form $x^2+2y^2$. This has nothing to do with $z$ being prime or not.