How can I generate positive integer solutions to $m$ and $n$ that satisfy the equation:
$4mn - m^2 + n^2 = ±1$,
subject to the constraints that $m$ and $n$ are coprime, $m-n$ is odd and $m > n$.
How can I generate positive integer solutions to $m$ and $n$ that satisfy the equation:
$4mn - m^2 + n^2 = ±1$,
subject to the constraints that $m$ and $n$ are coprime, $m-n$ is odd and $m > n$.
Hint: Completing the square yields an equation of the form: $x^2-Dy^2=\pm 1$ for a particular $D$.
There's actually a simple recursion that generates all solutions.
Let $a_0=0$, $a_1=1$, and $a_{k+2}=4a_{k+1}+a_{k}$. Then the general solution is $(m,n)=(a_{k+1},a_{k})$.
This gives the positive solutions. The solutions with $n$ negative are of the form $(m,n)=(a_k,-a_{k+1})$.
There are no solutions with $m$ negative and $m> n$