Prove that if $p \equiv 3 \pmod{4}$ then $x^2+y^2 \not \equiv 0 \pmod{p}$

Let $x$ and $y$ be integers not congruent to $0$ modulo $p$ where $p$ is a prime. Prove that if $p \equiv 3 \pmod{4}$ then $x^2+y^2 \not \equiv 0 \pmod{p}$.

I thought about proving this algebraically and by contradiction. So we say $x^2+y^2 = pz$ and have to show this is impossible.


Let $p$ be an odd prime such that $x^2+y^2 \equiv 0 \bmod p$ but $x,y \not\equiv 0 \bmod p$.

Let $z$ be the inverse of $y \bmod p$. Then $(xz)^2 \equiv -1 \bmod p$ and so $(xz)^4 \equiv 1 \bmod p$.

This means that $xz$ has order $4$ mod $p$ and so $4$ divides $p-1$, by Lagrange's theorem in group theory.


Assume to the contrary that $p \equiv 3 \pmod{4}$ and $x^2+y^2 \equiv 0 \pmod{p},$ where $p$ does not divide $x$ or $y$. Then we have $\left(\dfrac{x}{y}\right)^2\equiv -1 \pmod{p}, $ which contradicts the fact that $-1$ can not be a quadratic residue modulo such $p$.