Given a prime we want to find solutions to
Method 1: Find the solution of where
Expand into a simple continued fraction to the point where the denominators of its convergents satisfy the inequality Then
Proof: For any , we have
which is true for any continued fraction expansion.
Let
Take
We have
Therefore
Method 2:
Then :
If then satisfy
If , then satisfy
Proof:
Therefore
So we get
Hence we see the palindromic behaviour
If , then
Therefore so
By recursive relations,
We have
Expanding the determinants, we see
Therefore
(All of these ideas are related in some sense to Euclidean Algorithm in Gaussian integers, showing class number one for binary quadratic forms of discriminant )