Rational solutions for arbitrary p Let p be a prime, and by experimenting with various p, how can we guess a necessary and sufficient condition for x^2 + y^2 = p to have rational solutions. 
And how to prove the guess?
One thing I see is maybe using Sylvester's determinant, by how and why?
 A: Let $p$ be a prime number.
We claim that $x^2 + y^2 = p$ has a rational solution if and only if $p = 2$ or $p \equiv 1$ (mod 4).We assume we have the basic knowledge of the ideal theory of $\mathbb{Z}[\sqrt{-1}]$.
Let $K = \mathbb{Q}(\sqrt{-1})$.
Suppose $x^2 + y^2 = p$ has a rational solution.
Let $\gamma = x + \sqrt{-1}y \in K$.
Then $N(\gamma) = p$.
Let $A = \mathbb{Z}[\sqrt{-1}]$.
It is well known that $A$ is a principal ideal domain.
Suppose $\gamma = \alpha/\beta$, where $\alpha, \beta \in A$ and $\alpha$ and $\beta$ are relatively prime.
Then $N(\gamma) = N(\alpha)/N(\beta)$.
Hence $N(\alpha) = pN(\beta)$.
Since $\alpha$ and $\beta$ are relatively prime, $N(\alpha)$ and $N(\beta)$ are relatively prime.
Hence $N(\beta)$ is not divisible by $p$.
Since $N(\alpha)$ is divisible by $p$, there exists a prime ideal $P$ dividing $\alpha$ and $p$.
Then $N(P) = p$.
Hence $P \neq pA$.
Hence, by the theorem of the decomposition of a prime number in $K$, $p = 2$ or $p \equiv 1$ (mod 4).
Conversely suppose $p = 2$ or $p \equiv 1$ (mod 4).
There exists a prime ideal $P$ such that  $N(P) = p$.
Hence $x^2 + y^2 = p$ has an integer solution.
QED
