Modular Exponentiation Calculator
Work out modular exponentiation instantly with clear inputs, formula shown and shareable results.
About Modular Exponentiation Calculator
Repeated squaring computes bᵉ mod m in about log₂ e multiplications, reducing modulo m at each step so the numbers never grow. Computing bᵉ directly would be astronomically large.
Formula
Fast exponentiation
b^(2k) = (b^k)², b^(2k+1) = b·(b^k)², reducing mod m at every step
Worked example
With the default values below, Modular Exponentiation Calculator returns base^exponent mod m of 460. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Base
- 7
- Exponentminimum 0
- 128
- Modulusminimum 2
- 561
Results
- base^exponent mod m
- 460
- Squaring steps used
- 8
- Base reduced mod m
- 7
- Digits the direct power would have
- 108
Step by step
- 1Values used
- 2Fast exponentiation
- 3base^exponent mod m= 460
- 4Squaring steps used= 8
- 5Base reduced mod m= 7
- 6Digits the direct power would have= 108
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
What is 7¹²⁸ mod 561?
460. Since 561 = 3 × 11 × 17, the residues 1, 9 and 1 combine by the Chinese remainder theorem to give 460 — reached in just eight squarings.
Why does cryptography need this?
RSA and Diffie-Hellman raise numbers to exponents with hundreds of digits; only modular exponentiation makes that feasible.
Related Calculators
You might also need
- Modular Arithmetic CalculatorAlso in Discrete Math, Logic & Number Theory
- Discrete Logarithm CalculatorAlso in Discrete Math, Logic & Number Theory
- Adjacency Matrix CalculatorAlso in Discrete Math, Logic & Number Theory
- Base 64 Value CalculatorAlso in Discrete Math, Logic & Number Theory
- Bell Number CalculatorAlso in Discrete Math, Logic & Number Theory
- Binary To Decimal CalculatorAlso in Discrete Math, Logic & Number Theory
