CalculatorForEver
MATH / CALCULATOR

Modulo Calculator

Calculate modulo with worked steps, clear input conventions and a result table.

For positive modulus m, find integers q and r such that a = qm + r and 0 ≤ r < m. For −17 modulo 5, choose q = −4, so −17 = −4×5 + 3 and the result is 3.

Your numbers

BROWSER-LOCAL INPUTS

Your inputs stay in this browser. No account needed.

RESULT

Your result

Enter your values and select Calculate.

Check the units and assumptions before using this result.

METHOD

How the modulo calculator works

How to use this calculator

Enter the values in the stated format. Calculate and review the method, exact distinctions and any numerical limits before using the result.

What the result means

Modulo places an integer within a repeating cycle. With a positive modulus m, the Euclidean result lies from zero up to, but not including, m. This convention keeps a negative starting value within the same nonnegative cycle. It is useful for positions on a dial, repeating indexes and grouping tasks where a negative remainder would not name a usable slot. This calculator uses that explicit mathematical convention; a programming language’s percent symbol may follow a different rule for negative inputs.

The formula

Euclidean modulo = ((a % b) + b) % b

A worked example

−7 modulo 3 equals 2, using a nonnegative remainder.

Assumptions & methodology

Use consistent units and inspect the displayed working. Numerical results are rounded for display; unsupported or unstable inputs are rejected. Results are rounded for display; intermediate calculations retain precision. This tool is informational and does not replace institutional or professional guidance.

References

MDN: remainder and modulo conventions

WORK THROUGH THE DETAILS

Using your modulo result

Compare −17 modulo 5 with a truncating remainder

Truncating division takes −17/5 = −3.4 toward zero, yielding quotient −3. Substitution gives −17 − (−3×5) = −2, so the truncating remainder is −2. Euclidean modulo instead uses quotient −4 and remainder 3. Both decompositions satisfy dividend = quotient×divisor + remainder; their remainder rules differ. The separate Remainder Calculator uses the truncating convention. Name the convention when sharing a negative-input example so a reader can reproduce the same result.

Use modulo to wrap a position

Suppose five slots have labels 0 through 4 and you move backward two places from slot zero. The raw position is −2. Euclidean modulo gives −2 mod 5 = 3, so the wrapped position is slot 3. Moving forward eight places from that slot gives raw position 11, and 11 mod 5 = 1. Slot labels beginning at 1 require an offset: subtract one before wrapping and add one afterward. Mixing zero-based and one-based positions can shift an otherwise correct answer.

Check equivalent dividends without repeating the full division

Adding any whole multiple of the modulus preserves the modulo result. With modulus 7, the numbers 10, 17 and −4 all have result 3 because they differ by complete seven-unit cycles. This gives a quick consistency check for large or negative values. Modulo alone does not establish a calendar rule, hashing guarantee or encryption method; those applications add their own constraints. Stay within the supported exact-integer range so the dividend and product used in the division identity retain whole-number accuracy.

Use congruence as a check on the result

A modulo result r means the dividend and r differ by a multiple of the modulus. For −17 and result 3 at modulus 5, their difference is −20, which divides by 5 exactly. This relationship is written −17 ≡ 3 modulo 5. The congruence does not say the two integers are equal; it says they occupy the same cycle position. To verify a large entry, subtract the reported result from the original dividend and check divisibility by the positive modulus. The result must also satisfy the stated nonnegative range. Checking only divisibility would allow many equivalent values outside the chosen range.

INTERPRETATION

Understanding modulo results

Locate the enclosing multiples of the modulus

Multiples of 5 include −20, −15, −10, −5, 0 and 5. The integer −17 sits three units above −20. That offset of three is its modulo-five position. Positive 17 sits two above 15, so 17 modulo 5 is 2. The same positive modulus can produce different quotients while restricting each remainder to the same range. The quotient absorbs complete cycles; the result identifies the remaining position.

Apply the nonnegative-result convention consistently

A modulus of 5 permits results 0, 1, 2, 3 and 4. A result of 5 already completes another cycle and reduces to 0. Enter a positive, nonzero whole-number modulus in this tool. A negative dividend is permitted, but a negative modulus is outside this interface’s chosen convention. If you are reproducing software output, check that language’s documented operation before interpreting a different signed result as a calculation error.

RELATED GUIDES

Related questions and worked examples

Read a worked explanation before trying another calculation.

QUESTIONS

Modulo questions

What happens for an exact multiple?+

The modulo result is zero. For example, both 20 and −20 are exact multiples of 5, so each has modulo-five result 0.

Can the modulus be zero?+

No. Dividing a cycle into zero positions does not define a remainder range, so this calculator requires a positive modulus.