Modulo Calculator

Quick answer

A modulo calculator finds the remainder after dividing one number by another. The expression a mod b is what is left over when a is divided by b. So 17 mod 5 is 2, because 17 is three fives with 2 left over.

Updated 2026-09-09By Shakeel MuzaffarReviewed by Prof. Dr. Khalil Mudassar, PhD
Try
Number Theory
The number being divided.
The number you divide by. It cannot be zero.
a mod b
--
Quotient (floor)--
Remainder (truncated)--

Calculations run in your browser. Inputs are not sent to our servers; anything you Save stays in this browser only.

Saved results (0)

How to Use the Modulo Calculator

  1. Enter the dividend a, the number being divided.
  2. Enter the divisor b, which cannot be zero.
  3. Read a mod b, the remainder after division.
  4. See the quotient and the truncated remainder for comparison.

Here is what each result means:

ResultWhat it means
a mod bThe modulo, never negative for a positive divisor.
Quotient (floor)How many whole times b fits into a, rounded down.
Remainder (truncated)The remainder as most programming languages give it.

What Is the Modulo Operation?

The modulo operation gives the remainder after one number is divided by another. If you divide a by b, the modulo is what is left over. So 17 mod 5 = 2, because 5 goes into 17 three times with 2 remaining. When the remainder is zero, a is exactly divisible by b.

Modulo is everywhere in maths and computing. It tells you whether a number is even or odd, wraps a clock around after 12 hours, cycles through colors or list positions, and drives hashing and cryptography. It turns a straight number line into a repeating cycle of length b.

How Does the Modulo Calculator Work?

It divides a by b, takes the whole-number quotient, and returns what is left.

Relation: a = b x q + r where q is the quotient and r the remainder.
  1. Find how many whole times b fits into a.
  2. Multiply that quotient by b and subtract from a.
  3. The leftover is the remainder; for a positive divisor the modulo is never negative.

Modulo underpins the greatest common divisor; the GCD calculator uses repeated remainders to find it.

Modulo Example

Find 17 mod 5 and check whether 100 is even.

Calculation: 5 fits into 17 three times, using 15, so 17 mod 5 = 2. For 100, 100 mod 2 = 0, and a remainder of 0 means 100 is even. Any number with a remainder of 1 when divided by 2 is odd.

Remainder vs Modulo for Negatives

The two agree for positive numbers but can differ when the dividend is negative.

ExpressionTruncated remainderMathematical modulo
17 mod 522
-17 mod 5-23
17 mod -52-3

Most programming languages return the truncated remainder, which keeps the sign of the dividend. The mathematical modulo keeps the sign of the divisor, so it is never negative for a positive b.

Everyday Uses of Modulo

The repeating nature of modulo shows up in many places.

UseHow modulo helps
Even or oddA number mod 2 is 0 for even, 1 for odd
Clock timeHours wrap with mod 12 or mod 24
Cycling a listAn index mod length stays in range
Check digitsCard and ISBN checks use a modulo

Anywhere a count needs to wrap around and repeat, modulo is the natural tool.

What Affects the Result

The Size of the Divisor

The remainder is always smaller than the divisor, so a larger b allows a wider range of remainders.

The Sign of the Numbers

A negative dividend or divisor is where the truncated remainder and the mathematical modulo can differ.

Exact Division

When b divides a with nothing left over, both the remainder and the modulo are zero.

When to Use a Modulo Calculator

Programming and Logic

Check divisibility, wrap indexes, or work out cycles.

Number Theory Homework

Find remainders and explore divisibility rules.

Everyday Cycles

Work out clock arithmetic, repeating patterns or check digits.

Common Mistakes

1. Dividing by Zero

The divisor cannot be zero, since division by zero is undefined.

2. Expecting a Negative Modulo

For a positive divisor, the mathematical modulo is never negative, even when the dividend is negative.

3. Confusing Remainder and Quotient

The quotient is how many times b fits; the remainder is what is left over.

4. Assuming All Languages Agree

Programming languages differ on negatives. Check whether yours truncates or floors.

5. Thinking Modulo Needs Whole Numbers

Modulo also works on decimals, giving a decimal remainder smaller than the divisor.

Accuracy and Limitations

The remainder is exact for whole numbers; decimals may carry tiny floating-point effects.

What it calculates accurately

  • The remainder and mathematical modulo
  • The floor quotient
  • Divisibility, when the result is zero

What it does not do

  • Divide by zero
  • Give exact results for very long decimals
  • Solve modular equations or inverses
  • Work with complex numbers

How We Compute the Modulo

Method
The remainder from division, adjusted into the sign of the divisor for the modulo.
Inputs used
The dividend a and the divisor b.
Assumptions
A nonzero divisor; real numbers, whole or decimal.
Rounding
Results to six decimals for decimal inputs.
Edge cases
A zero result means exact division; negatives split remainder from modulo.
Sources
See Sources below.
Last reviewed
2026-09-08.

Frequently Asked Questions

What is the modulo operation?

It gives the remainder after dividing one number by another. So 17 mod 5 is 2, because 5 fits into 17 three times with 2 left over. A remainder of zero means the division is exact.

How do you calculate a mod b?

Divide a by b, take the whole-number quotient, multiply it back and subtract from a. Whatever is left is the remainder. This tool does it and shows the quotient too.

What is the difference between remainder and modulo?

They agree for positive numbers. For negatives they can differ: the truncated remainder keeps the sign of the dividend, while the mathematical modulo keeps the sign of the divisor and is never negative for a positive b.

Why can a modulo not be negative?

For a positive divisor, the mathematical modulo is defined to fall between zero and the divisor. So even a negative dividend gives a non-negative result, which is why -17 mod 5 is 3, not -2.

How do I check if a number is even?

Take the number mod 2. If the result is 0 it is even, and if it is 1 it is odd. The same idea checks divisibility by any number.

Can modulo be used on decimals?

Yes. The modulo of decimals gives a decimal remainder smaller than the divisor. For example, 5.5 mod 2 is 1.5. It is most common with whole numbers, though.

What is modulo used for in programming?

It checks divisibility, wraps list indexes so they stay in range, cycles through repeating patterns, and powers hashing and check digits. It is one of the most-used operators in code.

Why do programming languages differ on negatives?

Some truncate the quotient toward zero and some floor it, which changes the sign of the remainder for negative inputs. This tool shows both so there is no confusion.

Is my information saved?

No. The calculation runs in your browser and nothing you enter is stored or sent anywhere, unless you choose Save, which keeps the result only on this device.

Sources

Related Calculators

Looking for more math tools?

Explore all math calculators

This calculator finds the remainder when one number is divided by another. It shows both the truncated remainder, which matches most programming languages, and the mathematical modulo, which is never negative for a positive divisor. Spotted an error? Let us know.

Author

shakeel-Muzaffar
Founder & Editor-in-Chief at  ~ Web ~  More Posts

Shakeel Muzaffar is the Founder and Editor-in-Chief of MultiCalculators.com, bringing over 15 years of experience in digital publishing, product strategy, and online tool development. He leads the platform's editorial vision, ensuring every calculator meets strict standards for accuracy, usability, and real-world value. Shakeel personally oversees content quality, formula verification workflows, and the platform's commitment to publishing tools that are genuinely useful for students, professionals, and everyday users worldwide.