Modulo Calculator

Remainder after division

About This Calculator

The modulo operation returns the remainder after integer division of one number by another. It is widely used in programming for cyclic operations, determining even/odd numbers, clock arithmetic, and cryptography. The result of a mod m is always between 0 and m−1.

Formula

a mod m = a − m × floor(a / m)
Equivalently: the remainder when a is divided by m

Example Calculation

Find 17 mod 5.

  1. 17 ÷ 5 = 3 remainder 2 (since 3 × 5 = 15)
  2. 17 − 15 = 2
17 mod 5 = 2

Modulo Results (a mod m)

amod 2mod 3mod 5mod 7mod 10
111111
202222
310333
401444
512055
600166
711207

Frequently Asked Questions

What is the modulo operator used for in programming?
Common uses include checking if a number is even (n mod 2 == 0), cycling through an array index (i mod length), and implementing clock or calendar arithmetic.
How does modulo work with negative numbers?
Results differ by language. In Python, −7 mod 3 = 2 (always non-negative). In C/Java, −7 % 3 = −1 (same sign as the dividend). Check your language's definition.
Is modulo the same as the remainder?
For positive numbers, yes. They differ for negative numbers depending on rounding direction. Python's modulo always returns a non-negative result for positive divisors.