Xerobit

Modulo Calculator: Find the Remainder of Any Division

A modulo calculator finds the remainder when one integer is divided by another. Enter your dividend and divisor below to see the remainder, the full quotient and the underlying formula. The calculation runs entirely in your browser, so no data is sent anywhere.

Result

  • Remainder
    2

    17 mod 5

  • Quotient
    3

    Integer part of the division

  • Formula
    17 = 5 × 3 + 2

    a = n × q + r

How to use the modulo calculator

  1. Enter the dividend, which is the number you want to divide.
  2. Enter the divisor, the number you are dividing by. It must be a non-zero integer.
  3. Read the remainder in the result area immediately.
  4. Check the quotient and formula rows to see how the modulo operation was computed.

How the modulo operation works

The modulo operation returns the remainder after dividing one integer by another. In mathematics it is written as a mod n. Most programming languages use the percent sign: a % n.

The relationship between the four parts is defined by the equation a = n * q + r, where a is the dividend, n is the divisor, q is the integer quotient and r is the remainder. The remainder always satisfies 0 <= r < |n| under the Euclidean convention.

For example, to compute 17 mod 5: divide 17 by 5 to get a quotient of 3. Multiply back: 5 times 3 equals 15. Subtract that from 17 to get a remainder of 2. So 17 mod 5 is 2.

Common modulo examples

This table shows several inputs and their results using Euclidean division, which always produces a non-negative remainder.

Dividend (a)Divisor (n)Quotient (q)Remainder (r)
10331
10520
71007
-103-42
10-3-31
0400

Notice that when the dividend is smaller than the divisor, the quotient is zero and the remainder equals the dividend itself.

Practical uses for remainders

Programmers rely on the modulo operation constantly. A few everyday applications include:

  • Even or odd checks: n % 2 === 0 means the number is even.
  • Circular buffers: wrapping an index around an array of length L uses index % L.
  • Clock arithmetic: adding hours on a 12-hour clock is done mod 12. If it is 10 o'clock and you add 5 hours, (10 + 5) mod 12 = 3, so the time is 3 o'clock.
  • Checksums: algorithms like ISBN-10 and Luhn use modular arithmetic to detect typing errors.
  • Cryptography: RSA encryption depends heavily on modular exponentiation with very large primes.

Negative numbers and different conventions

When either the dividend or the divisor is negative, the sign of the remainder depends on the convention used. This modulo calculator follows Euclidean division, which guarantees a non-negative remainder satisfying 0 <= r < |n|. Under this rule the quotient rounds toward negative infinity when needed. For instance, -17 mod 5 yields a quotient of -4 and a remainder of 3, because 5 times -4 plus 3 equals -17.

Languages like C, Java and JavaScript instead use truncated division, rounding the quotient toward zero. Under truncated division, -17 mod 5 gives a quotient of -3 and a remainder of -2. Python and Ruby use floored division, which matches the Euclidean result for positive divisors but can differ when the divisor is negative. Always check which convention your programming language or textbook uses before relying on a specific sign.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
Simple positive numbersDividend (a): 17; Divisor (n): 5Remainder: 2; Quotient: 3; Formula: 17 = 5 × 3 + 2
Evenly divisibleDividend (a): 20; Divisor (n): 4Remainder: 0; Quotient: 5; Formula: 20 = 4 × 5 + 0
Negative dividendDividend (a): -17; Divisor (n): 5Remainder: 3; Quotient: -4; Formula: -17 = 5 × -4 + 3
Large valuesDividend (a): 1000000; Divisor (n): 7Remainder: 1; Quotient: 142,857; Formula: 1,000,000 = 7 × 142,857 + 1

FAQ

What does modulo mean?

Modulo is a mathematical operation that finds the remainder after dividing one integer by another. For example, 10 modulo 3 is 1 because 3 goes into 10 three times with 1 left over.

Is modulo the same as the remainder?

In most programming contexts yes. Strictly speaking, some definitions of modulo always return a non-negative result, while the remainder operator in languages like C and JavaScript can return a negative value when the dividend is negative.

Can I use decimals in this modulo calculator?

No. The modulo operation is defined for integers. If you enter a decimal, the calculator will show an error. Convert your values to whole numbers first if possible.

What happens if the divisor is zero?

Division by zero is undefined in mathematics, so the modulo operation cannot be performed. This tool will display an error message if you enter zero as the divisor.

Why is my remainder never negative here?

This calculator uses Euclidean division, which always produces a non-negative remainder between 0 and the absolute value of the divisor minus one. Languages like C and JavaScript use truncated division instead, which can yield a negative remainder when the dividend is negative.

How do I calculate modulo without a calculator?

Find the largest multiple of the divisor that does not exceed the dividend (rounding toward negative infinity if needed). Subtract that product from the dividend. The difference is the remainder.