This is an exam question from Number theory (especially of quadratic field extensions):
For which prime number $p$ can we solve the Diophantine equation $x^2-31y^2=-p$. Find also a solution for $p=3$.
I have the following solution: For $x^2-31y^2=1$ we can use the fundamental unit for $\Bbb{Z}[\sqrt{31}]$. This is given by $\epsilon=1520-273\sqrt{31}$ with $N(\epsilon)=1$. Thus for $x^2-31y^2=(x-y\sqrt{31})(x+y\sqrt{31})$ we find $x=\pm1520$ and $y=\pm273$. But how to find the $p$ and the other solutions? I thought over the factorization of $1520$ and $273$ and common prime divisor and $x^2-31y^2=-p$ equivalent with $-\frac{1}{p}(x^2-31y^2)=1$. But how to go on?