Solving a generalized Pell equation

We investigate the solubility in positive integers of the diophantine equation ax2-by2=±1, where 1 < a < b, gcd(a,b)= 1 and ab is not a perfect square.
In the case of solubility, we return the least positive solution.
The algorithm used was pointed out by Jim White and is described in a note.
A BC version is available here.

Enter a (> 1):
Enter b (> a, gcd(a,b)=1, ab not a perfect square):
Enter e (0 or 1):

Last modified 8th May 2012
Return to main page