Overview
Exponentiation by Squaring rewrites an exponent in binary. It squares the base each step and multiplies the result only when the current exponent bit is set.
Computes powers efficiently by repeatedly squaring the base and using the exponent's binary digits.
Compact metadata for implementation and discovery.
Exponentiation by Squaring rewrites an exponent in binary. It squares the base each step and multiplies the result only when the current exponent bit is set.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n log n)
Worst
O(n^2)
Space
O(n)
if bit is 1: result = result * base; base = base * baseUses the binary expansion of the exponent to reduce multiplications.
Show squaring the base and multiplying only when a binary exponent bit is set on a small fast exponentiation example.
The same pattern works for matrices and modular residues when the operation has an identity and is associative.
What each reference supports for this entry.
Reference for Exponentiation by Squaring's arithmetic operations, modular arithmetic, multiplication, division, or number-theoretic implementation details.
Open sourceTextbook support for Exponentiation by Squaring's algorithm family, complexity framing, and standard implementation concepts.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Cryptography · Foundation
Classic Diffie-Hellman computes public values with modular exponentiation.
Compare with thisCryptography · Foundation
Modular exponentiation applies the same squaring pattern while reducing modulo m.
Compare with thisCryptography · Foundation
RSA public and private operations are modular exponentiations.
Compare with thisModular exponentiation applies the same squaring pattern while reducing modulo m.
RSA public and private operations are modular exponentiations.
Classic Diffie-Hellman computes public values with modular exponentiation.