Modulo Calculator

Compute the remainder of a division (dividend mod divisor). Enter any dividend and divisor to find the modulo, the quotient (integer part of the division), and the related floor-modulo result.

Remainder (a mod n)2
Quotient (integer part)
3
Floor modulo (sign of divisor)
2

Uses mod(dividend, divisor) following standard truncated division: the remainder takes the sign of the dividend. The floor-modulo output instead always matches the sign of the divisor. The divisor cannot be 0.

What the Modulo Calculator Does

This Modulo Calculator finds the remainder left over after one number is divided by another. You enter a dividend (a) and a divisor (b), and the tool returns the modulo result, written as a mod b. Where ordinary division tells you how many times b fits into a, the modulo operation tells you what is left behind.

It is useful for students checking arithmetic, programmers working with cyclic logic, and anyone solving problems involving cycles, grouping, or repetition. Common real-world uses include determining the day of the week, distributing items evenly, wrapping clock values around 12 or 24, and checking whether a number is even or odd.

How It Works: The Modulo Formula

The modulo operation is defined in terms of integer division. If you divide a by b and take the whole-number quotient q, the remainder r is whatever is left:

remainder = a โˆ’ (b ร— q), where q = floor(a รท b)

Written as a function, that is r = mod(a, b). The remainder is always smaller in magnitude than the divisor. For positive numbers, the result ranges from 0 up to b โˆ’ 1. A result of 0 means b divides a exactly with nothing left over.

Worked Example With Real Numbers

Suppose you want 17 mod 5. First divide: 17 รท 5 = 3.4, so the whole-number quotient is 3. Multiply back: 5 ร— 3 = 15. Subtract from the original: 17 โˆ’ 15 = 2. Therefore 17 mod 5 = 2.

A second example: 24 mod 8. Here 24 รท 8 = 3 exactly, and 8 ร— 3 = 24, so 24 โˆ’ 24 = 0. The remainder is 0, which confirms 8 divides 24 evenly.

Negative Numbers and a Common Pitfall

Negative inputs are where many people get tripped up, because the answer depends on how the quotient is rounded. Using the floor (round-down) convention, the remainder takes the sign of the divisor.

For โˆ’17 mod 5: floor(โˆ’17 รท 5) = floor(โˆ’3.4) = โˆ’4. Then โˆ’17 โˆ’ (5 ร— โˆ’4) = โˆ’17 + 20 = 3, so the result is 3. Many programming languages instead truncate toward zero, which would give โˆ’2 for the same inputs. Always check which convention your language or tool uses before trusting a negative result.

Practical Tips and Factors That Affect the Result

Keep these points in mind to avoid mistakes and use modulo effectively:

  • Dividing by zero is undefined โ€” b must not be 0, just as with normal division.
  • Checking parity is simple: n mod 2 equals 0 for even numbers and 1 for odd numbers.
  • To test if a is divisible by b, check whether a mod b equals 0.
  • The result's range is fixed by the divisor: for a positive b, valid remainders are 0 through b โˆ’ 1.
  • Modulo is ideal for wrapping values, such as hours on a clock: 14 mod 12 = 2, giving 2 PM.
  • Decimals can have remainders too: 7.5 mod 2 = 1.5, since 2 fits three times (6) with 1.5 left.

Frequently asked questions

What is the modulo operation?

The modulo (or mod) operation returns the remainder left over after dividing one number (the dividend) by another (the divisor). For example, 17 mod 5 = 2 because 17 = 3 x 5 + 2.

Why does the result sometimes differ from another calculator?

There are two common conventions. Truncated modulo (used here for the main result) gives a remainder with the same sign as the dividend, while floor modulo gives a remainder with the same sign as the divisor. We show both so you can pick the one your context needs.

Can the divisor be zero?

No. Division by zero is undefined, so the divisor must be a non-zero number for the modulo to have a meaningful value.

Does this work with decimals?

Yes. Modulo is defined for non-integer values too. For example, 5.5 mod 2 = 1.5.