Toolzent

Modulo Calculator

Free modulo calculator that finds the remainder of a divided by b, plus the quotient and the always-positive modulo, for any whole or negative numbers.

Updated 2026-06-09 · Free · No sign-up · Runs privately in your browser

"Remainder" follows the sign of the dividend (like most programming languages); "positive modulo" is always 0 or greater.

What is a modulo calculator?

A modulo calculator finds the remainder that is left over when you divide one number by another. Enter a dividend a and a divisor b, press Calculate, and this tool returns the remainder of a ÷ b, the whole-number quotient, and the always-positive modulo. It handles whole numbers and negative numbers, which is where most by-hand mistakes happen.

The modulo operation (often shortened to mod, and written % in code) answers a simple question: after dividing as many whole times as possible, what is left? For 17 mod 5, five fits into seventeen three times to reach 15, leaving 2 behind. That leftover 2 is the result. Modulo shows up everywhere from clock arithmetic and calendars to hashing, cryptography and checking whether a number is even or odd.

How does the modulo calculator work?

The tool computes the remainder of a ÷ b and reports three values at once.

  • Remainder: the leftover after dividing. By the rule this calculator uses, the remainder takes the sign of the dividend a, exactly as in C, Java, JavaScript and most other programming languages. The primary formula is a mod b = remainder of a ÷ b.
  • Quotient: the whole-number part of the division, trunc(a ÷ b) — the division truncated toward zero, dropping any fractional part.
  • Positive modulo: a version that is always 0 or more, found with ((a % b) + |b|) % |b|, where |b| is the absolute value of the divisor. This is the convention used in pure mathematics and in languages like Python.

The three results are linked by the division identity a = b × quotient + remainder. In words: the dividend equals the divisor times the quotient, plus whatever is left over. You can always check a modulo result by plugging the quotient and remainder back into that equation.

Key terms

  • Dividend (a): the number being divided.
  • Divisor (b): the number you divide by, also called the modulus.
  • Quotient: how many whole times b fits into a.
  • Remainder / modulo: what is left after the whole division.

Examples

Each example below matches the calculator exactly. Type the inputs into the tool above to reproduce them.

Example 1: 17 mod 5

  • 5 divides into 17 three whole times: 5 × 3 = 15, so the quotient is 3.
  • The leftover is 17 - 15 = 2, so the remainder is 2.
  • Both dividend and divisor are positive, so the positive modulo is also 2.

Example 2: 20 mod 4

  • 4 divides into 20 exactly five times: 4 × 5 = 20, so the quotient is 5.
  • Nothing is left over, so the remainder is 0.
  • A remainder of 0 means 20 is evenly divisible by 4. The positive modulo is 0 as well.

Example 3: -7 mod 3

  • Dividing toward zero, -7 ÷ 3 truncates to a quotient of -2 (3 × -2 = -6).
  • The leftover is -7 - (-6) = -1, and because the remainder follows the dividend’s sign, the remainder is -1.
  • The positive modulo is 2, from ((-1) + |3|) % |3| = (-1 + 3) % 3 = 2 % 3 = 2.

This third case shows why the two outputs differ for negative inputs: the signed remainder is -1, but the always-positive modulo is 2.

Modulo reference table

This table shows common modulo results, including how the sign of the dividend changes the remainder. Each row matches the rules above.

a (dividend)b (divisor)Quotient (trunc)RemainderPositive modulo
175322
204500
35033
102500
-73-2-12
7-3-211

Notice that when a is negative the remainder is negative, and the positive modulo adds |b| to bring it back into the range 0 up to |b| - 1.

What is modulo used for?

The modulo operation is one of the most widely used calculations in computing and everyday math:

  • Even or odd checks. n mod 2 returns 0 for even numbers and 1 for odd, the standard test in nearly every program.
  • Clock and calendar arithmetic. Wrapping a 24-hour clock back to a 12-hour one, or finding the day of the week, both rely on modulo to “wrap around” at a fixed point.
  • Hashing and indexing. Hash tables map a key to a slot with hash mod table-size, keeping the index inside the array bounds.
  • Cryptography. Modular arithmetic underpins RSA and many other algorithms, where huge numbers are reduced modulo a key value.
  • Cycling through items. Looping over a fixed set, such as colors or turns in a game, uses index mod count to return to the start.
  • Divisibility. A remainder of 0 means a is exactly divisible by b, the quick way to test factors.

Tips and common mistakes

  • Mind the sign convention. This tool’s remainder follows the dividend, so -7 mod 3 is -1, while the positive modulo is 2. If your language or textbook expects the always-positive result, use the positive modulo field.
  • Quotient truncates toward zero. -7 ÷ 3 becomes -2, not -3. Truncation drops the fraction rather than rounding down, which keeps the identity a = b × quotient + remainder consistent with the signed remainder.
  • Dividing by zero is undefined. The divisor b cannot be 0, because there is no remainder for division by zero.
  • A bigger dividend is fine. Modulo works for any size, and when a is smaller than b the answer is simply a itself, with a quotient of 0.
  • Remainder 0 means divisible. If you only need a yes-or-no divisibility test, check whether the remainder equals 0.

Limitations and notes

This modulo calculator runs entirely in your browser, so the numbers you enter never leave your device. It is built for integer modulo, the most common use of the operation; very large values are subject to the standard floating-point limits of your device, which can affect precision far beyond ordinary whole-number ranges. The default remainder follows the dividend’s sign to match common programming languages, while the positive modulo always returns a value from 0 up to |b| - 1; choose the one your assignment, specification or codebase requires. Division by zero has no defined remainder and is not supported.

For more number tools, try the percentage calculator, the prime number calculator and the LCM and GCF calculator in the full math calculators category.

Frequently asked questions

What is a modulo calculator?+

A modulo calculator finds the remainder left over when one number is divided by another, so 17 mod 5 returns 2 because 5 goes into 17 three times with 2 left over.

What does mod mean in math?+

Mod is short for modulo, the operation that returns the remainder of a division rather than the quotient, written as a mod b or a % b in most programming languages.

What is 17 mod 5?+

17 mod 5 = 2, because 5 divides into 17 three whole times (quotient 3) with a remainder of 2 left over.

What is the remainder of -7 mod 3?+

Following the dividend's sign, -7 mod 3 gives a remainder of -1, while the always-positive modulo is 2, calculated as ((-1) + 3) % 3.

Why do some calculators give a different sign for the modulo?+

The sign depends on the convention: this tool follows the dividend, like C, Java and JavaScript, while the positive modulo uses ((a % b) + |b|) % |b| to always return 0 or more.

What is the difference between modulo and division?+

Division gives the quotient, the whole-number part of a ÷ b, while modulo gives only the remainder that is left after that division is complete.

What is a mod b when a is smaller than b?+

When the dividend is smaller than the divisor the quotient is 0 and the remainder is just the dividend itself, so 3 mod 5 = 3.

Does this modulo calculator work with negative numbers?+

Yes, it accepts negative dividends and divisors and shows both the signed remainder and the always-positive modulo so you can match whichever convention you need.