Theorem 6
For
![$ n$](img9.gif)
a squarefree integer, the equation
![$ x^2-2y^2=n$](img137.gif)
has a solution
in integers if and only if it has a solution modulo
![$ n$](img9.gif)
.
Proof.
By multiplicativity, it suffices to show that
![$ x^2-2y^2=n$](img137.gif)
has a solution
for
![$ n=-1$](img138.gif)
,
![$ n=2$](img139.gif)
, and
![$ n=p$](img140.gif)
for
![$ p$](img55.gif)
an odd prime such that
![$ 2$](img83.gif)
is congruent
to a square modulo
![$ p$](img55.gif)
. For
![$ n=-1$](img138.gif)
, use
![$ 1^2-2\cdot 1^2=-1$](img141.gif)
; for
![$ n=2$](img139.gif)
,
use
![$ 2^2 - 2\cdot 1^2 = 2$](img142.gif)
.
Now suppose
![$ p$](img55.gif)
is an odd prime such that
![$ 2$](img83.gif)
is congruent to a square
modulo
![$ p$](img55.gif)
. Find
![$ x,y$](img143.gif)
such that
![$ x^2-2y^2$](img144.gif)
is divisible by
![$ p$](img55.gif)
but not
by
![$ p^2$](img72.gif)
(if it is divisible by
![$ p^2$](img72.gif)
, fix that by replacing
![$ x$](img30.gif)
with
![$ x+p$](img145.gif)
). Now form the ideal
![$ (x+y\sqrt{D}, p)$](img146.gif)
. Its norm divides
![$ p^2$](img72.gif)
and
![$ x^2-2y^2$](img144.gif)
, so it must be
![$ p$](img55.gif)
.