Modular Exponentiation

Calculate (base^exp) % mod efficiently using binary exponentiation.

Code

Algorithms
pow(base, exp, mod)

Parameters

Base number

Exponent

Modulus

Server

More Python Snippets