ThisCalculator

Everyday

Calculator Modulo: Find the Remainder of a Division

Updated · Standard formula, shown below

Modulo remainder 2
Quotient rounded down
3
Result
Dividend
17
You entered
Divisor
5
You entered

Calculator Modulo: Find the Remainder of a Division

A modulo calculator finds the remainder left after one integer is divided by another. Enter the dividend and a nonzero divisor to get the modulo result, with an example below showing how the calculation works.

Formula

The calculator uses the floor-remainder formula:

r = a − b × floor(a / b)

  • a is the dividend, the number being divided; it has no physical unit here.
  • b is the divisor, which must not be zero; it has no physical unit.
  • floor(x) means the greatest integer less than or equal to x.
  • r is the remainder. For a positive divisor, this convention gives 0 ≤ r < b.

The quotient output, q = floor(a / b), is included to help explain the calculation. For nonnegative integers, this is the ordinary whole-number quotient. The first output is the modulo remainder, which is the main result.

Worked Example

Using the default values, a = 17 and b = 5:

  1. Divide: 17 / 5 = 3.4.
  2. Round down: floor(3.4) = 3, so the whole-number quotient is 3.
  3. Multiply the quotient by the divisor: 5 × 3 = 15.
  4. Subtract from the dividend: 17 − 15 = 2.

The modulo remainder is 2, and the quotient rounded down is 3. This matches 17 = 5 × 3 + 2.

What Modulo Means

Modulo describes the remainder pattern created by division. In the statement 17 modulo 5, written 17 mod 5, the answer is 2 because five fits into seventeen three times, with two left over. If a number divides evenly, the remainder is zero: 20 mod 5 = 0.

Modulo is also used to group integers by their remainders. For example, numbers that leave remainder 2 when divided by 5 include 2, 7, 12, and 17. They are said to be congruent modulo 5; in symbols, 7 ≡ 2 (mod 5). This is a relationship between numbers, not a claim that the numbers are equal in ordinary arithmetic.

How to Use a Modulo Calculator

  • Enter the dividend, the number you want to divide.
  • Enter a nonzero divisor.
  • Read the remainder as the modulo result. The quotient output can help verify it.

For ordinary whole-number use, enter integers. The calculator’s formula also works mathematically with non-integer values, but many programming languages define remainder or modulo operations specifically for integers. Check the tool or language’s convention before relying on decimal inputs.

Where Modulo Is Useful

Modulo is useful whenever a process repeats in fixed-size cycles. A familiar example is a clock: adding 5 hours to 10 o’clock gives 3 o’clock on a 12-hour clock, because 15 mod 12 = 3. The remainder wraps the count back into the cycle.

Other common uses include:

  • Checking divisibility: an integer is divisible by n when its remainder modulo n is zero.
  • Finding repeating positions: rotating through a list of 8 items can use an index modulo 8 to keep positions in the range 0 to 7.
  • Even or odd tests: an integer is even when n mod 2 = 0 and odd when n mod 2 = 1.
  • Calendar and cycle arithmetic: remainders help express recurring patterns, though real calendars can have additional rules.

Negative Numbers and Calculator Differences

For positive integers, the remainder is straightforward. Negative dividends expose a difference between two conventions. This calculator uses the floor-based modulo rule, so with a positive divisor the result stays between zero and one less than the divisor. For example, −7 mod 5 = 3, because −7 = 5 × (−2) + 3.

Some programming languages instead use truncation toward zero to calculate a signed remainder. Under that convention, −7 remainder 5 is −2. The two results are not contradictory: they follow different definitions. When comparing results across calculators or writing code, check whether the operation is mathematical modulo (often called floor modulo) or a remainder operator based on truncation.

A zero divisor is undefined: there is no valid quotient or modulo result for division by zero. The calculator therefore requires a nonzero divisor. Also, the remainder’s sign and range depend on the chosen convention, especially when either input is negative.

Frequently Asked Questions

What is 17 modulo 5?
It is 2. Five goes into 17 three times, and 2 remains.

What is the difference between modulo and remainder?
For nonnegative integers, the terms usually produce the same result. With negative values, “remainder” may use truncation toward zero while modulo may use floor division, so the answers can differ.

Can the divisor be zero?
No. Modulo by zero is undefined, just as division by zero is undefined.

What does a remainder of zero mean?
The dividend is exactly divisible by the divisor. For example, 24 mod 6 = 0.

How do I calculate modulo by hand?
Find the whole-number quotient, multiply it by the divisor, then subtract that product from the dividend. For 29 mod 6, 6 × 4 = 24 and 29 − 24 = 5.

Related

Formula used
in a | Dividend | - | 17 | 0
in b | Divisor | - | 5 | 0
out r | Modulo remainder | - | a - b * floor(a / b) | 0
out q | Quotient rounded down | - | floor(a / b) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.