Modulo Calculator

Find the remainder after division, with both the programming and mathematical conventions.

What the Modulo Calculator does

The modulo operation returns what is left over after division. It drives clock arithmetic, cycling through lists, checksum digits and hashing.

Formula

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

Inputs explained

InputUnitRequiredNotes
Dividend (a)numberYes
Divisor (n)numberYes

How to use it

  1. Enter Dividend (a) and Divisor (n).
  2. Select Calculate.

Worked example

It is 9 o'clock. What time is it 20 hours later on a 12-hour clock?

Dividend
29
Divisor
12

29 mod 12 = 5, so 5 o'clock.

Reading the result

  • Modulo answers what is left over: 17 mod 5 is 2, because 17 is three fives with two remaining.
  • It is the arithmetic of anything that wraps around — clock faces, days of the week, and stepping through a list back to the start.

Common mistakes

  • Assuming every language agrees on negative operands. C, Java and JavaScript give the remainder the sign of the dividend, while Python and Ruby follow the divisor, so −7 mod 3 is −1 in one group and 2 in the other.
  • Using a divisor of zero, which is undefined for the same reason division by zero is.

Frequently asked questions

Why do languages disagree about negative modulo?

They choose different rounding for the quotient. Truncating toward zero gives −1 for −7 mod 3; flooring gives 2. Both are internally consistent.

Related calculators