Modular Arithmetic

Modular Arithmetic

Local Processing

Compute modular power (base^exp) mod m using fast binary square-and-multiply algorithm without integer overflow.

How It Works & Processing Standards

Enter values above to calculate results automatically. Check each input field for guidance and units.

Tool processing runs in your browser. If you create a calculator or conversion share link, its values are included in the URL. See the privacy policy for account, analytics and advertising data.

Finds remainders of big calculations quickly and exactly. Choose power, sum or product under "Calculation".

What You Can Do

Modular exponentiation
base^exp mod m by repeated squaring — even 3^200.
Modular sum and product
(a + b) mod m and (a × b) mod m

How to Use Modular Arithmetic

  1. 1
    Choose a calculationPower, sum or product.
  2. 2
    Enter numbersIntegers and a modulus m greater than 0.
  3. 3
    Read the resultA remainder from 0 to m − 1.

Examples

3^200 mod 13
Input: Base 3, exponent 200, modulus 13
Result: 9
123456 × 654321 mod 1000
Input: a 123456, b 654321, m 1000
Result: 376

Common Use Cases

  • Working through RSA or Diffie–Hellman examples by hand
  • The last digits of a huge number
  • Checking number theory or coding problems

Frequently Asked Questions (FAQ)

What about negative numbers?

The result is always shown between 0 and m − 1.

Can the exponent be very large?

Yes. Repeated squaring keeps it fast.

Have feedback or ideas for this tool? Suggest & Inquire →