### Testing Dujella's unicity conjecture

The conjecture states that the diophantine equation x2 - (k2 + 1)y2 = k2 has at most one positive solution (x,y) with 1 ≤ y < k-1. (For background, see slides.)

We test the conjecture for k in the range m ≤ k ≤ n, where n < 105, exhibiting the k for which an exceptional solution exists.

If (x,y) is an exceptional solution, let d = gcd(x + k, x − k), a = gcd((x + k)/d, k2 + 1), b = gcd((x − k)/d, k2 + 1), p2 = (x+k)/da, q2 = (x-k)/db. Then ab = k2 + 1, 2 < a, 2 < b, gcd(a,b) = 1, d divides 2k, (d distinct from k and 2k, and d is even if k is odd) and ap2 - bq2 = 2k/d with gcd(p,q)=1.

(p,q) is found by considering the initial period of the continued fraction of √(b/a) (we can assume a < b by interchange): if d > 1, then p/q = Am/Bm (a convergent), where Qm+1 = 2k/d, whereas if d = 1, then p/q = (Am + eAm-1)/(Bm + eBm-1), (a quasi-convergent) where | Qm - Qm+1 + 2ePm+1 | =2k.

We verify that the unicity conjecture holds for k, by showing that there is at most one (d,a,b) for which a solution (p,q) exists and in the case of solubility, that we have precisely one solution (p,q) of ap2 - bq2 = ± 2k/d with gcd(p,q)=1 and satisfying dpq < k-1.

Enter m (1 < m < 1010 ):
Enter n (1 < m ≤ n < 1010 ):