$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · hard · #316

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: >> (also accepted: >>)

Shifting the exponent right by one halves it and exposes the next bit, giving O(log e) multiplications.
Play Problem Solving ▸