What goes in the blank?
# fast modular power: square the base, halve the exponent
r = 1
while e:
if e & 1:
r = r * b % m
b = b * b % m
e ____= 1
Answer: >>
Shifting the exponent right by one halves it and exposes the next bit, giving O(log e) multiplications.
Play Problem Solving ▸