Exponentiation by squaring
This algorithm is much faster than the ordinary method to compute such a value. Multiplying x by itself, n operations are needed to calculate x n. With the method shown above, only log2(n) operations are needed.