Pell's equation

Solving x2 - Ny2 = 1.

Enter a positive non-square integer for N into the box and click "Go!". The smallest integer solution for x will be found, using Bhaskara II's method. Each step of the calculation will be displayed below the final solution. [For some really bad values for N, see OEIS A033316. For example you may enjoy trying 1021 for N.]