I came across this problem and I believe Lagrange's theorem is the key to its solution. The question is:
Let $p$ be an odd prime. Prove that there is some integer $x$ such that $x^2 \equiv −1 \pmod p$ if and only if $p \equiv 1 \pmod 4$.
I appreciate any help. Thanks.