Math Fundamentals18 sections · 814 units
Open in Course

Super Pow - Insight

Break down large exponents

The key insight: a1234=a1230×a4=(a123)10×a4a^{1234} = a^{1230} \times a^4 = (a^{123})^{10} \times a^4. You can process the exponent digit by digit from left to right.

For each digit dd, raise the current result to the 10th power, then multiply by ada^d. Apply mod at every step to keep numbers small.

This uses the property (x×y)modm=((xmodm)×(ymodm))modm(x \times y) \mod m = ((x \mod m) \times (y \mod m)) \mod m that you learned earlier.