Skip to content
AllCalcHub

Modulo Calculator

Find the remainder when one whole number is divided by another (a mod n), including negative numbers.

About the Modulo Calculator

The modulo operation gives the remainder after division. Clocks work modulo 12: 15 o'clock is 15 mod 12 = 3.

For negative numbers, maths uses a remainder that is never negative, while many programming languages keep the sign of the dividend. Both are shown.

The formula

a mod n = a − n × ⌊a ÷ n⌋

⌊ ⌋
round down to a whole number

Worked example

−7 mod 3

  1. ⌊−7 ÷ 3⌋ = −3
  2. −7 − 3 × (−3) = 2
  3. (JavaScript's −7 % 3 gives −1)

Questions people ask

What is 10 mod 3?

1, because 10 = 3 × 3 + 1.

Where is modulo used?

Clocks and calendars, checking even and odd numbers, hashing, and check digits on cards and barcodes.