# Solution of generalized Pell's equation for k ≠ ±1 or k ≠ ± 4.

I'd been searching the internet for hours and finally I've found and understood the solution of Pell's equation of the form x² - D·y² = 1.

However, I got stuck for the solution of x² - D·y² = c, where D = 20 and c = 80·k, k being any integer other than zero.

For the equation x² - 20·y² = 1, starting with [x0, y0, k0] = [5, 1, 5],

(5)² - 20·(1)² = 5

and using Bhaskara's cyclic method (derived from Brahmagupta's identity),

[x1, y1, k1] = [(m·x0 + D·y0) / k, (x0 + m·y0) / k, (m² - D) / k]

choosing m = 5 leads to the first solution as [x1, y1] = [9, 2]

composing [x1, y1] with itself leads to the second solution

[x2, y2] = [161, 36]

further composing [x1, y1] with [x2, y2] leads to the third solution

[x3, y3] = [2889, 646]

So far, so good...

Where I fail to understand is, how do I jump from the solution x² - 20·y² = 1 into x² - 20·y² = 80 or x² - 20·y² = 160 (x² - 20·y² = 80·k in general).

Can anybody explain in short? Any helpful internet link would be sufficient and would be appreciated as well.

• Have you read the Mathworld article? In particular, it points out that $x^2-D y^2=c$ has a solution for $|c|<\sqrt{D}$ if and only if $c=p_n^2-Dq_n^2$ where $p_n$ and $q_n$ are the numerator and denominator of a continued fraction convergent to $\sqrt{D}$. It states that if $|c|>\sqrt{D}$ the procedure is more complicated, and gives a reference. – rogerl Feb 1 '17 at 22:52
• You didn't have to search the internet, though it can be useful. just search this site and especially answers by Will Jagy. If you want to find his answers, just go to his profile page and look them up. – user25406 Feb 2 '17 at 0:45