Modulo Calculator

Modulo gives the remainder after division and is used in clock arithmetic, calendars, programming and checksums.

Results update as you type.

−17 mod 5

3

mathematical modulo (never negative)

Remainder (truncated, as in C, Java, JavaScript %)
−2
Quotient (rounded down)
−4

For positive numbers both answers are the same; they differ when the dividend is negative.

About this calculator

For negative numbers, maths and most programming languages give different answers; the calculator shows both.

How to use it

  1. Enter the dividend.
  2. Enter the divisor.
  3. Read both results.

The formula

a = n × q + r, with 0 ≤ r < |n|
r
the mathematical modulo
%
truncated remainder in many languages

Worked example

−17 mod 5

  1. Mathematical modulo: 3, because −17 = 5 × (−4) + 3.
  2. JavaScript −17 % 5 = −2.

What the result means

The result is always between 0 and the divisor, which is the mathematical convention. In Python, % gives the same answer for a positive divisor; in C, Java and JavaScript a negative dividend gives a negative remainder.

Mathematical modulo and truncated remainder compared

With a negative divisor, this calculator still keeps the answer between 0 and |n|, so 17 mod −5 = 2. Python’s % follows the sign of the divisor instead and gives 17 % −5 = −3, so check which convention your code expects.

The two answers differ only when the dividend is negative
ana mod n (maths)a % n (C, Java, JavaScript)
17522
−1753−2
−11211−1
−131211−1
−732−1
−2573−4
7−311
0400
121200

Everyday uses of modulo

  • Day of the week: 100 days after a Monday, 100 mod 7 = 2, so it is a Wednesday.
  • 24-hour clock: 9 hours after 20:00 is (20 + 9) mod 24 = 5, that is 05:00.
  • Odd or even: n mod 2 is 0 for even numbers and 1 for odd numbers.
  • Divisibility: 84 mod 7 = 0, so 84 is a multiple of 7.

Assumptions

  • Real numbers.

Limitations

  • The divisor cannot be zero.

Frequently asked questions

What is 17 mod 5?

2.

What is −1 mod 12?

11 in mathematics.

Is modulo the same as remainder?

For positive numbers yes; for negatives they can differ.

What is 10 mod 3?

1, because 10 = 3 × 3 + 1.

What is 5 mod 10?

5. When a positive dividend is smaller than the divisor, the dividend itself is the remainder.

Can modulo be used with decimals?

Yes. 7.5 mod 2 = 1.5, because 7.5 = 2 × 3 + 1.5.

Last reviewed on 12 October 2026. How we calculate and check. Found a mistake? Tell us.