Calculate the square root of “N.” The ratio of “x” to “y” in the fundamental solution will be an approximation of the square root of “N”, and the ratios for larger values of “x” and “y” will be increasingly close to the actual square root. If “N” is a perfect square, then the equation can be solved by factoring the equation into (x-my)(x+my)=1, where “m” is the square root of “N.” Solving for this yields another trivial answer, which is not of much concern. If the original equation were x² - 23y² = 1, you would find the square root of 23, which is approximately 4.79583.
Compute the continued fraction equivalent of the square root, until the expansion begins to repeat. A continued fraction is a nested complex fraction preceded by the integer portion of the square root. The fractional part consists of the integer “1” divided by another integer plus one divided by another integer plus one divided by another integer, etc., or A + 1/(B + 1/(C + 1/(D…))), where “A,” “B,” “C,” and “D” are integers. The square root of 23 would be approximated by the continued fraction 4 + 1/(1 + 1/(3 + 1/(1 + 1/(8 + …))), after which the fractions begin to repeat.
Drop the portion of the fraction that begins to repeat, and the last element of the original cycle. In the example above, 1/8 and everything after it would be dropped, leaving 4 + 1/(1 + 1/(3 + 1/1)).
Simplify the fraction. The resulting ratio represents the fundamental solutions for the value of “x” over the value of “y.” The fraction above simplifies to 24/5, so the values of “x” and “y” for x² - 23y² = 1 are 24 and 5, respectively.