Modulo Calculator

The modulo operation returns the remainder when one integer is divided by another. Given a dividend a and a positive divisor n, the result a mod n is the unique integer r satisfying a = n * q + r where 0 <= r < n and q is an integer (the quotient). Modulo is a cornerstone of number theory and computing: it underlies hash tables, ring buffers, day-of-week calculations, and the entire field of modular arithmetic used in cryptography. This calculator uses the mathematical convention where the result is always non-negative, regardless of the sign of a. Enter the dividend and divisor to see the quotient and remainder.

Any integer (positive or negative)
Positive integer
2.00
3.00

Modulo formula

a mod n = a - n * floor(a / n)
Result is always in range [0, n-1] for positive n
Division check: a mod n = 0 means n divides a exactly

The floor function rounds down to the nearest integer (toward negative infinity), ensuring the remainder is always non-negative. For example, -7 mod 3 = -7 - 3 * floor(-7/3) = -7 - 3 * (-3) = -7 + 9 = 2.

Modulo in practice

  • Day of week: if today is Monday (day 1), 100 days later is (1 + 100) mod 7 = 101 mod 7 = 3 (Wednesday).
  • Clock: 14 hours after 10:00 = (10 + 14) mod 24 = 24 mod 24 = 0 (midnight).
  • Even/odd: n is even if n mod 2 = 0; odd if n mod 2 = 1.
  • Divisibility: n is divisible by 3 if n mod 3 = 0.
  • Hash tables: store item with key k in bucket k mod table_size.

Modulo calculator: frequently asked questions

What is the modulo operation?

The modulo operation (a mod n) returns the remainder when a is divided by n. For example, 17 mod 5 = 2 because 17 = 3 * 5 + 2. The result always satisfies 0 &lt;= (a mod n) < n for positive n.

How does modulo work with negative numbers?

Conventions differ. In mathematics, the result of a mod n is always non-negative (truncated toward negative infinity). In many programming languages (including C and Java), the sign of the remainder matches the sign of the dividend. This calculator uses the mathematical convention: the result is always non-negative.

What is modulo used for?

Modulo is used in computing for cyclic operations (clock arithmetic: 13:00 mod 12 = 1), hash tables (bucket index = key mod size), cryptography (most operations are mod a large prime or composite), and checking divisibility (a is divisible by n if and only if a mod n = 0).

What is clock arithmetic?

Clock arithmetic (modular arithmetic) is arithmetic modulo n. Hours on a 12-hour clock are mod 12: 11 + 3 = 14, but 14 mod 12 = 2, so 3 hours after 11:00 is 2:00. Days of the week use mod 7.

How is modulo different from integer division?

Integer division gives the quotient (floor(a/n)), while modulo gives the remainder. They are related by the division algorithm: a = n * floor(a/n) + (a mod n). For example, 17 = 5 * 3 + 2, so 17 div 5 = 3 and 17 mod 5 = 2.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 15 June 2026. See our methodology.