Exponentiating by squaring is an algorithm. It is used for quickly working out large integer powers of a number. It is also known as the square-and-multiply algorithm or binary exponentiation. It uses the binary expansion of the exponent. It is of quite general use, for example in modular arithmetic.
The algorithm is believed to have first been documented in the Sanskrit book Chandah-sûtra, about 200 BC.