Algorithm
One way of calculating and is to use Newton's method to find a solution for the equation, giving the recursive formula
The sequence converges quadratically to as . It can be proven that if is chosen as the initial guess, one can stop as soon as
to ensure that
Read more about this topic: Integer Square Root