Skip to main content
math

Modulo Calculator

Calculate the remainder when one integer is divided by another. The modulo operation a mod n returns the remainder r such that a = qn + r with 0 ≤ r < n.

Reviewed by Chase FloiedUpdated

This free online modulo calculator provides instant results with no signup required. All calculations run directly in your browser — your data is never sent to a server. Enter your values below and see results update in real time as you type. Perfect for everyday calculations, homework, or professional use.

Must be a non-zero integer

Results

Remainder (a mod n)

2

Quotient

3

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Modulo Calculator. Most fields include unit selectors so you can work in your preferred unit system — metric or imperial, whichever matches your problem.

2

Review your inputs

Double-check that all values are correct and that you have selected the right units for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Modulo Calculator instantly computes the output and displays results with units clearly labeled. All calculations happen in your browser — no loading time and no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

Formula Reference

Modulo Calculator Formula

See calculator inputs for the governing equation

Variables: All variables and their units are labeled in the calculator interface above. Input fields accept values in multiple unit systems — select your preferred unit from the dropdown next to each field.

When to Use This Calculator

  • Use the Modulo Calculator when you need a quick mathematical result without writing out all the steps manually, saving time on repetitive calculations.
  • Use it to verify hand calculations on tests or assignments and catch arithmetic mistakes.
  • Use it when teaching or explaining mathematical concepts to others, demonstrating how changing inputs affects the result.
  • Use it to explore the behavior of mathematical functions across a range of inputs.

About This Calculator

The Modulo Calculator is a free mathematical calculation tool for students, educators, and professionals who need quick, reliable results. Calculate the remainder when one integer is divided by another. The modulo operation a mod n returns the remainder r such that a = qn + r with 0 ≤ r < n. The underlying algorithms implement well-established mathematical formulas and numerical methods. Results are computed instantly in the browser. This tool is useful for learning, verification of hand calculations, and rapid exploration of mathematical relationships. All computation happens locally — no data is sent to a server.

About Modulo Calculator

The modulo operation (often written as a mod n or a % n in programming) finds the remainder after dividing one integer by another. If you divide 17 by 5, the quotient is 3 and the remainder is 2, so 17 mod 5 = 2. Modular arithmetic is sometimes called 'clock arithmetic' because clock hours wrap around — 15:00 is the same as 3:00 PM because 15 mod 12 = 3. The modulo operation is fundamental in computer science (hash functions, cryptography, circular buffers), number theory (congruences, Fermat's little theorem, Chinese remainder theorem), and everyday applications like determining days of the week, ISBN check digits, and cyclic patterns. Programming languages differ in how they handle negative dividends — some return negative remainders while the mathematical convention uses non-negative remainders.

The Math Behind It

In number theory, a ≡ b (mod n) means n divides (a − b), defining an equivalence relation that partitions the integers into n residue classes. The integers modulo n form the ring Z/nZ, which is a field if and only if n is prime. Key theorems include: Fermat's little theorem (a^(p−1) ≡ 1 mod p for prime p and gcd(a,p)=1), Euler's theorem (a^φ(n) ≡ 1 mod n for gcd(a,n)=1), and the Chinese Remainder Theorem (a system of congruences with coprime moduli has a unique solution modulo the product of the moduli). Wilson's theorem states (p−1)! ≡ −1 (mod p) for prime p. Modular exponentiation a^b mod n can be computed efficiently using repeated squaring, which is crucial for RSA and Diffie-Hellman cryptography. The modular inverse of a modulo n exists if and only if gcd(a, n) = 1, and can be found using the extended Euclidean algorithm.

Formula Reference

Modulo Operation

a mod n = a − n × floor(a/n)

Variables: a = dividend, n = divisor (n ≠ 0)

Worked Examples

Example 1: Basic Modulo

Calculate 23 mod 7

Step 1:Divide: 23 ÷ 7 = 3 remainder 2
Step 2:Verify: 7 × 3 + 2 = 21 + 2 = 23 ✓

23 mod 7 = 2

Example 2: Modulo with Negative Dividend

Calculate −10 mod 3 (mathematical convention)

Step 1:Floor division: floor(−10/3) = floor(−3.33...) = −4
Step 2:Remainder: −10 − 3 × (−4) = −10 + 12 = 2

−10 mod 3 = 2 (mathematical convention, always non-negative)

Common Mistakes & Tips

  • !Confusing remainder with modulo for negative numbers — programming languages vary in convention.
  • !Thinking a mod n can be greater than or equal to n — the remainder is always in [0, n−1].
  • !Dividing by zero — modulo by zero is undefined.
  • !Applying modulo properties incorrectly: (a + b) mod n = ((a mod n) + (b mod n)) mod n, but (a − b) mod n requires care with negative results.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

What is the difference between mod and remainder?

Mathematically, a mod n is always non-negative (0 ≤ r < n). In many programming languages, the % operator returns a remainder that may be negative when the dividend is negative. The mathematical modulo always adjusts to give a non-negative result.

Why is modular arithmetic important in cryptography?

Modular arithmetic enables one-way functions: computing a^b mod n is fast, but reversing the operation (discrete logarithm) is computationally hard for large n. RSA and Diffie-Hellman rely on this asymmetry.