Mathematics calculator

Power Modulo Calculator

Find the least nonnegative remainder of a large integer power without constructing the full power.

Calculator inputs

Enter your values

Modular exponentiation
Calculated output

Result summary

Your result will appear here

Complete the required fields and select the calculate button.

Repeated squaring steps reducing powers around a modular number cycle
Repeated squaring reduces after each multiplication, avoiding an enormous intermediate power.

What Is Modular Exponentiation?

The Power Modulo Calculator finds the remainder left by an integer power. Instead of first writing a number such as 37200, it repeatedly reduces smaller products by the divisor. That makes a calculation practical even when the full power would contain hundreds of digits.

Modular powers appear in number theory, repeating schedules, checksums and introductory cryptography exercises. This page accepts an integer base, a whole-number exponent from zero upward and a positive integer divisor. It reports the standard least nonnegative remainder, so the answer is always from zero through one less than the divisor.

How to Calculate a Power Modulo a Number

  1. Enter Integer base x between −1,000,000,000 and +1,000,000,000. A negative base is allowed.
  2. Enter Nonnegative exponent y as an integer from 0 through 1,000,000,000.
  3. Enter Positive modulus n as an integer from 1 through 1,000,000,000. It does not need to be prime.
  4. Select Calculate. Read the remainder, expression, reduced base, result range and repeated-squaring method label.

The calculator reduces the base into 0 through n − 1 before it processes the exponent. It then repeatedly squares and reduces smaller residues. It never needs to construct the entire power xʸ. The displayed answer is an integer remainder, so there is no decimal rounding step.

An exponent of zero initializes the result as 1 mod n. This implementation also uses that convention for 0⁰; it does not settle every mathematical context in which 0⁰ appears. If n = 1, every result is 0. Negative exponents are not accepted because they would require a separate modular-inverse calculation.

Repeated Squaring Formula and Method

r = xʸ mod n, with 0 ≤ r < n

Reduced base x₀ = ((x mod n) + n) mod n

If y is odd: r ← (r × x₀) mod n

Each step: x₀ ← x₀² mod n; y ← floor(y ÷ 2)

Start with r = 1 mod n, and repeat the steps while the remaining exponent is positive. Whenever an exponent bit is 1, multiply the accumulated remainder by the current squared residue. Halving the exponent moves to its next binary digit.

The Stanford modular exponentiation notes explain repeated squaring. Reducing after multiplication preserves the final remainder while keeping intermediate values small. This algorithm works with composite moduli as well as prime moduli; it does not require Fermat’s little theorem.

For a small hand calculation, write the exponent as a sum of powers of 2, compute the needed squared residues, then multiply just those residues. The worked example follows that procedure so you can check the final remainder independently.

Base, Exponent, Modulus and Remainder

Integer base x
Signed integer being raised to a power, bounded to ±10⁹.
Exponent y
Whole number from 0 through 10⁹. It selects how many repeated factors the power represents.
Modulus n
Integer from 1 through 10⁹. It defines the possible residues, not a percentage.
Power modulo result r
Featured least nonnegative remainder. It is not the full power or a quotient.
Reduced base
Representative of x in the range 0 through n − 1.
Expression and result range
Confirm the entered power and its allowed remainder interval.
Method
Repeated squaring, which reduces after each multiplication instead of forming the entire power.

Modular Exponentiation Worked Example

Illustrative example. Find 7¹³ mod 19. Write 13 = 8 + 4 + 1. Repeated squaring gives 7² ≡ 11, 7⁴ ≡ 7 and 7⁸ ≡ 11, all modulo 19.

Select the factors for exponents 8, 4 and 1: 7¹³ ≡ 11 × 7 × 7. Reduce as you multiply: 11 × 7 = 77 ≡ 1, then 1 × 7 ≡ 7.

As a separate check, the full small-example power is 96,889,010,407 = 19 × 5,099,421,600 + 7. The calculator avoids constructing such a full power for large exponents.

Calculation check. These illustrative values were checked independently against the formula and calculator response. Retain unrounded intermediate values when checking approximations.

Modular Exponentiation Worked Example
Power or stepResidue modulo 19
7¹7
7² = 4911
7⁴ ≡ 11²7
7⁸ ≡ 7²11
7¹³ ≡ 11 × 7 × 77

Zero Powers, Negative Bases and Modulus One

These cases explain why the result range and exponent convention matter. The modulus must remain positive, and the exponent must remain nonnegative.

Zero Powers, Negative Bases and Modulus One
ExpressionResultReason
(−4)³ mod 112−64 = −6 × 11 + 2
9⁰ mod 71Zero exponent starts with 1
0⁰ mod 71This calculator’s computational convention
0⁵ mod 70Positive power of zero
9⁸ mod 10Only residue modulo 1

How to Interpret a Modular Power

Read the output as a remainder class. A result of 2 means that the original power differs from 2 by an exact multiple of the divisor. It does not mean that the power equals 2, nor does it give the quotient. When the divisor is 1, the only possible remainder is 0.

For hand checking, try a smaller exponent or build a short list of repeating residues. Modular powers often repeat, although the cycle depends on the base and modulus. A zero result means the divisor divides the power exactly. It does not necessarily mean the base itself is zero.

This calculator is suitable for arithmetic study and verification. Security systems use carefully chosen large values and reviewed libraries; a small web calculation should not be used to design or assess a cryptographic system.

The input bounds are tied to the implementation’s native integer arithmetic. On this 64-bit installation, the product of two residues below 10⁹ stays below 10¹⁸ and fits the integer range. This is still a bounded arithmetic tool, not an arbitrary-length integer or cryptographic key calculator.

Negative bases need particular care in hand checks. For example, (−4)³ = −64 is congruent to 2 modulo 11 because −64 = −6 × 11 + 2. A programming language’s signed remainder may print a negative number unless you normalize it to the nonnegative range used here.

Common Power Modulo Mistakes

  • Entering a decimal base or exponent even though modular exponentiation here is defined on integers.
  • Using a negative exponent, which would require a modular inverse and is outside this form.
  • Entering zero as the divisor. Division by zero has no remainder.
  • Calculating the full power on an ordinary calculator first and losing precision before taking the modulus.
  • Keeping a negative programming remainder without converting it to the least nonnegative representative.
  • Reading “mod” as a percentage or as division that returns a quotient.

Frequently Asked Questions

What does power modulo mean?

It means the least nonnegative remainder after an integer power is divided by a positive modulus. For 7¹³ mod 19, the remainder is 7.

Why use repeated squaring?

It reduces after each multiplication and processes the exponent through its binary digits. This avoids first constructing the entire large power.

Can the base be negative?

Yes. This page normalizes negative bases and returns a nonnegative residue. For example, (−4)³ mod 11 is 2.

Must the modulus be prime?

No. Repeated squaring works for any supported positive integer modulus. No prime-modulus condition is needed for this calculation.

What happens when the exponent is zero?

The calculator returns 1 mod n. It also follows that computational convention for 0⁰, so 0⁰ mod 7 is 1 here.

Why is every result modulo 1 equal to zero?

The allowed remainder range is 0 through n − 1. For n = 1, that range contains only 0.

Can I use a negative exponent?

No. Negative modular powers require an invertible base and a modular inverse. This form accepts exponents from 0 through 10⁹ only.

Is the result the full value of the power?

No. It is a remainder, not the complete power or quotient. The expression and range cards help you check what was evaluated.

Sources and References