Math

Modular Exponentiation Calculator

Compute a large integer power modulo a positive integer without constructing the full power.

Exact method explained belowEditable inputs
Calculation notebook
Calculation notebook

The formula and worked example below explain the calculation.

See the method

Enter your values

Runs on your device

Your answer

Your result

Let’s calculate.

Use the Calculate button to see your result.

Review the method below for assumptions and conventions.

How to use this tool

  1. Enter base, nonnegative exponent, positive modulus.
  2. Select Calculate to view the result.
  3. Check the method and assumptions below before using the result.

Input reference and sample values

Use the units and choices shown for each field. Sample values are provided for practice, not as recommendations.

InputFormat and unitsSample
BaseEnter text using the format shown in the sample.7
Nonnegative exponentEnter text using the format shown in the sample.128
Positive modulusEnter text using the format shown in the sample.13

Result for these sample inputs

3

Select Try the example in the form to load these values and calculate them again. This replaces the current form inputs. Compare the result with the method and worked explanation below.

The method, explained

Repeated squaring reduces each product modulo m while processing exponent bits. This computes a^e mod m with bounded intermediate integer values.

A WORKED EXAMPLE

Using base = 7, nonnegative exponent = 128, positive modulus = 13, the result is 3. Change these example inputs to match your task; use the method above to check each step.

What to keep in mind

At most 200 digits per input. Educational arithmetic; not a constant-time cryptographic implementation. Finite-precision arithmetic is used. Check the domain and the stated convention before using an approximation.

Common questions

Does it calculate the enormous power first?

No. Reducing after every multiplication gives the same remainder while avoiding the memory cost of representing the full integer power.

How can I check the result?

Repeated squaring reduces each product modulo m while processing exponent bits. This computes a^e mod m with bounded intermediate integer values. The worked example uses editable inputs. Calculations run on your device; no external API or account is required.

Methodology maintained by ClarityKit. How these tools are built and checked.