Number System

Modular Exponentiation

A comic-style dial appears beside geometric tokens representing successive powers.

Modular Exponentiation definition

Modular exponentiation computes the remainder of an integer power with respect to a positive modulus.

In Spanish
exponenciación modular
Topic
Integer equations and number theory

Modular Exponentiation in a picture

Modular Exponentiation diagramCompute 2⁵ mod 7 by using powers 2⁴ and 2¹.Square 2 to get 4 modulo 7This represents 2²Square 4 and reduce to 2This represents 2⁴Multiply by 2 and reduce2⁵ gives remainder 4
Compute 2⁵ mod 7 by using powers 2⁴ and 2¹.

How it works

Reduce the base first and reduce after each multiplication. To handle large nonnegative exponents, repeatedly square to obtain powers with exponents 1, 2, 4, and so on. Multiply the powers corresponding to the binary expansion of the desired exponent.

Worked examples

Find 3² mod 5.

9 leaves remainder 4.

Find 3⁴ mod 5.

Square the remainder 4. Then 16 mod 5 = 1.

Find 3⁵ mod 5.

Multiply the previous remainder 1 by 3 to get 3.

Common mistake

You can reduce the base and intermediate products modulo m. The exponent cannot generally be reduced modulo m.

Quick check

What is 5³ mod 7?

What speeds up large exponents?

Show answer

Repeated squaring.

What is 9⁰ mod 7?

Show answer

1.

Sources

Flashcard

Modular Exponentiation

Reveal the definition

Modular exponentiation computes the remainder of an integer power with respect to a positive modulus.

Effortless Math. “Modular Exponentiation.” Math Dictionary.