Sumivo · Mathematics

Modulo Calculator

Find a mod n — the remainder of integer division — with the quotient and both remainder conventions, so negative dividends are unambiguous.

01 / inputs

integer
integer

02 / result

A MOD N

2

Result (Euclidean)
2
Truncated remainder
2
Quotient
3

Calculation trace

  1. 17 = 3 × 5 + 2
    2
    Division algorithm
  2. 17 mod 5 = 2
    2
    Euclidean modulo
§

How it works

Modulo is the remainder left after integer division. By the division algorithm, for a dividend a and a non-zero modulus n there is a unique quotient q and remainder r with a = q·n + r. This tool reports the Euclidean modulo, where the result is always kept in the range 0 ≤ r < |n|, and it also shows the truncated remainder returned by the % operator in C, Java and JavaScript, whose sign follows the dividend. The two agree when the dividend is non-negative and differ when it is negative — for example −7 mod 3 is 2 in the Euclidean sense but −1 as a truncated remainder.

Assumptions & limits

  • Both the dividend and the modulus must be integers; decimals and non-numeric values are rejected.
  • The modulus cannot be 0, because division by zero is undefined.
  • The main result uses the Euclidean convention (non-negative, 0 ≤ result < |modulus|); the truncated remainder is shown alongside it for programming contexts.
  • The quotient is the integer q that satisfies dividend = q × modulus + result exactly.
§

FAQ

What does modulo mean?
The modulo (or “mod”) is the remainder after dividing one integer by another. For 17 mod 5 the quotient is 3 and the remainder is 2, so 17 mod 5 = 2.
Why does this tool show two different remainders for negative numbers?
There are two common conventions. The Euclidean modulo always returns a non-negative result (0 ≤ r < |n|), so −7 mod 3 = 2. The truncated remainder used by the % operator in C, Java and JavaScript keeps the sign of the dividend, so −7 % 3 = −1. Both describe the same division; they just place the remainder differently. Python’s % and spreadsheet MOD use the Euclidean result.
Can the modulus be zero?
No. Dividing by zero is undefined, so a modulus of 0 is rejected.
What is modulo used for?
Wrapping values into a fixed range (clock arithmetic, array indices), checking divisibility (a is divisible by n when a mod n = 0), generating cyclic patterns, hashing, and checksum digits all rely on the modulo operation.
§

Related calculators

§

SOURCES