Nonnegative modulo calculator

Find the exact remainder. Check the signed division.

Calculate Euclidean modulo

NONNEGATIVE REMAINDER · r

3

INTEGER QUOTIENT · q

−4

−17 = 5 × (−4) + 3

Euclidean convention: 0 ≤ r < |b|. Here, 0 ≤ 3 < 5.

Remainder within 0 ≤ r < 5

5

Truncating remainder comparison

For example, JavaScript %

Remainder −2 · Quotient −3

−17 = 5 × (−3) − 2

The divisor cannot be zero. Negative divisors use the same nonnegative remainder convention.

Signed integers only, up to 100 digits. No decimals, commas or exponents.

How it works

1

Enter signed integers

Type any integers for the
dividend a and divisor b.

2

Compute the nonnegative remainder

The tool computes the remainder r
and quotient q with 0 ≤ r < |b|.

3

Check the identity

Verify that a = b × q + r and
that 0 ≤ r < |b|.

Worked example

−17 = 5 × (−4) + 3, with 0 ≤ 3 < 5.

The comparison uses a different quotient convention; it is not a contradictory result.

Questions, Answered.

Why is −17 mod 5 equal to 3 here?

The Euclidean convention chooses a remainder between zero and 5, with 5 excluded. The quotient is −4 because −17 = 5 × (−4) + 3.

Can the divisor be negative?

Yes. The remainder remains in 0 ≤ r < |b|. For −17 and −5, q = 4 and r = 3.

Why does a programming remainder sometimes differ?

Languages can choose different quotient and remainder conventions. JavaScript % uses truncation toward zero, giving −17 % 5 = −2. This calculator explicitly uses a nonnegative Euclidean remainder.

Remainder Challenge

Turn a cycle into a little challenge.

Generate your own practice problems and
strengthen your understanding of modulo
with visual cycles and signed divisions.

Create my challenge →