Modular Exponentiation

Medium · Math & Number Theory · about 15 minutes

Asked at Google, Coinbase, Stripe, Plaid, Ramp, American Express, Rippling, Brex, Mercury.

Given non-negative integers base, exp and a modulus mod (1 ≤ mod ≤ 10⁹ + 7), return base^exp mod mod. exp can be as large as 2³¹ − 1, so computing the full power is impossible.