Math Fundamentals18 sections · 814 units
Open in Course

Lessons from Super Pow

summary

1.1. When the exponent is too large to fit in an integer, break it into pieces. Use ab=(ab÷10)10×abmod10a^{b} = (a^{b \div 10})^{10} \times a^{b \mod 10} to process one digit at a time.

2.2. Modular exponentiation is your friend. Apply modulo after every multiplication to keep numbers small and avoid overflow.

3.3. Recursion simplifies digit-by-digit processing. Each recursive call handles one digit, and the base case handles the empty array.