3 ms·
Exponentiation is done through repeated squaring, e.g. x^21 = x^16 * x^4 * x ... = (((x^2)^2)^2)^2 * (x^2)^2 * x Integer square roots can be done us
by cs137 4y ago
Exponentiation is done through repeated squaring, e.g.
x^21 = x^16 * x^4 * x
... = (((x^2)^2)^2)^2 * (x^2)^2 * x
Integer square roots can be done using binary search, which is O(n) for an n-bit number, but Newton's method can be used and it's usually much faster.