Finding primitive solutions of the diophantine equation ax2+bxy+cy2=n, where b2-4ac < 0, gcd(a,b,c)=1 and a > 0, n > 0.


This uses a forgotten continued fraction method of Lagrange.
See Oeuvres de Lagrange, 725-726.

A description of the algorithm is at Lagrange's Algorithm Revisited: Solving at2+btu+cu2=n in the Case of Negative Discriminant, Journal of Integer Sequences, Vol. 17 (2014), Article 14.11.1.

E = 1 is verbose.

Enter a: (> 0)
Enter b:
Enter c: (gcd(a,b,c)=1 and b2-4ac < 0)
Enter n (> 0):
Enter E (0 or 1):

Last modified 28th August 2014
Return to main page