Modulo Calculator

Enter two whole numbers to find the remainder when the first is divided by the second.

Cannot be 0.

This result is an estimate only. Double-check important figures before relying on them.

How it is calculated

  • Quotient = a ÷ n, rounded down
  • Remainder = a − n × quotient
  • The sign-of-a version is the remainder when dividing and rounding towards zero

For related whole-number tools, see the prime number calculator.

Worked example

17 mod 5:

  • Quotient = 3, remainder = 17 − 15 = 2
  • For −7 mod 3, the result is 2, while a language that keeps the sign of a gives −1

Why your number may differ

Programming languages disagree on negative results. Python gives 2 for −7 % 3, but JavaScript and C give −1.

Frequently asked questions

What does mod mean?

a mod n is the remainder left after dividing a by n. For example 17 mod 5 = 2, because 17 = 3 × 5 + 2.

How are negative numbers handled?

The main result follows the mathematical convention, with a remainder from 0 up to n − 1 for a positive n. Many programming languages instead keep the sign of a, so that result is shown too.

Where is modulo used?

In clock arithmetic, checking whether a number is even or odd, check digits and cycling through lists.