PellEquation MOD Challenging

Problem - 2310

Let $p$ be a prime. Prove that the equation $x^2-py^2 = -1$ has integral solution if and only if $p=2$ or $p\equiv 1\pmod{4}$.


If the considered equation has a solution $(x, y)$, then $p \mid x^2+1$. Hence either $p=2$ or $p\equiv 1 \pmod{4}$ because $p$ is a prime.

For $p=2$, $(x, y)=(1, 1)$ is a solution.

We now show that for each prime $p=4t+1$, there exists at least one solution. For this, consider the fundamental solution $(x_0, y_0)$ to its corresponding equation $x^2 -py^2=1$.

We observe $x_0$ is odd: otherwise $y^2_0 \equiv py_0^2\equiv 3\pmod{3}$. Thus in the relationship $x_0^2 - 1= (x_0-1)(x_0+1) = py_0^2$, factors $(x_0+1)$ and $(x_0-1)$ have the greatest common divisor 2. Consequently one of them is a double square (i.e. $2x^2$), and the other one $2p$ times a square (i.e. $apy^2$). The case $x_0+1 = 2x^2$ and $x_0-1=2py^2$ is impossible because it leads to a smaller solution of $x^2-py^2=1$. It follows that $x_0-1=2x^2$, $x_0+1=2py^2$, and therefore $x^2-py^2=-1$.

report an error