Modulo — Definition, Formula & Examples
Modulo is an operation that gives you the remainder when one number is divided by another. For example, 17 modulo 5 equals 2, because 17 ÷ 5 = 3 with a remainder of 2.
Given integers and where , the expression yields the unique integer such that and , where is an integer. The value is the remainder of the Euclidean division of by .
Key Formula
Where:
- = The number being divided (the dividend)
- = The number you divide by (the modulus), must be positive
- = The quotient (how many whole times n fits into a)
- = The remainder, which is the result of the modulo operation
How It Works
To compute , divide by and keep only the remainder. If the division comes out evenly, the result is 0. For instance, because 4 goes into 12 exactly 3 times with nothing left over. You will often see the word "mod" written between two numbers, or the symbol used in programming languages to mean the same thing.
Worked Example
Problem: Find 23 mod 7.
Divide: Divide 23 by 7 to find the quotient.
Verify: Check by multiplying the quotient by 7 and adding the remainder.
State the result: The remainder is 2, so the answer is 2.
Answer:
Why It Matters
Modulo is used constantly in computer science for tasks like determining whether a number is even or odd (), cycling through lists, and cryptography. In everyday life, clock arithmetic is modulo 12 — fifteen hours after 1 o'clock lands on 4 o'clock because , and .
Common Mistakes
Mistake: Confusing the modulo result with the quotient.
Correction: Modulo gives the remainder, not how many times the divisor fits. For , the answer is 2 (the remainder), not 3 (the quotient).
