Overview

The modulo operation gives the remainder after division. It is used for clocks, calendars, even/odd checks and hash functions.

Enter a dividend and a divisor; negative numbers are handled both mathematically and as in programming languages.

Worked examples

InputsResult
Dividend100Divisor7100 mod 7 = 2Quotient: 14Check: 7 × 14 + 2 = 100Truncated remainder (like % in code): 2
Show 3 more examples
Dividend17Divisor517 mod 5 = 2Quotient: 3Check: 5 × 3 + 2 = 17Truncated remainder (like % in code): 2
Dividend-17Divisor5-17 mod 5 = 3Quotient: -4Check: 5 × -4 + 3 = -17Truncated remainder (like % in code): -2
Dividend1,000Divisor131000 mod 13 = 12Quotient: 76Check: 13 × 76 + 12 = 1000Truncated remainder (like % in code): 12

Modulo by dividend

With the calculator's starting values, the result is 2. The table shows how it changes with the dividend.

DividendModulo
604
803
100starting value2
1201
1400

Other inputs: Divisor: 7. Change them in the calculator above for your own numbers.

How it works

a mod b = a − b × floor(a ÷ b). The result always has the same sign as the divisor, unlike the % operator in many languages, which keeps the sign of the dividend.

The formula

a mod b = a − b × ⌊a ÷ b⌋
aDividend
bDivisor (not 0)

Practical tips

  • An integer is even if n mod 2 = 0.
  • Clock arithmetic is mod 12: 15 o’clock is 3.

Frequently asked questions

What is 100 mod 7?

2, because 7 × 14 = 98 and 100 − 98 = 2.

What is −7 mod 3?

2 mathematically, −1 with the truncated % operator.