Direct answer
Two integers are congruent modulo a positive modulus when their difference is divisible by that modulus, so they occupy the same position in the repeating residue cycle.
What this calculation tells you
Working modulo n replaces the infinite number line with n residue classes. Addition and multiplication can be reduced before or after the operation without changing the final class.
Programming languages may use different remainder conventions for negative dividends, so the mathematical least-nonnegative residue and a language operator are not always identical.
Where it is used
Time and calendars
Model recurring positions such as hours or weekday offsets.
Computing
Wrap indices and partition integer keys with explicit collision limits.
Number theory
Study divisibility, inverses, and congruence equations.
Patterns and puzzles
Track repeating states without enumerating every step.
Common situations
- Finding a clock position after an offset.
- Reducing a large power to a residue pattern.
- Wrapping an array index.
- Checking whether a modular inverse can exist.
Think in residue classes
Modulo 5, for example, every integer belongs to one of five classes. Numbers in the same class differ by a multiple of five.
Reduce compatible operations
You may reduce operands during addition and multiplication. Division is different: it requires an invertible divisor and cannot be cancelled casually.
Specify negative-remainder conventions
A least-nonnegative convention returns a value from zero through n minus one for positive n. Some software instead keeps the sign of the dividend.
Common mistakes
Frequent errors include treating congruence as equality and dividing by a value with no modular inverse.
- Require a nonzero modulus.
- Declare the residue range.
- Verify inverses by multiplication.
Practical questions
Frequently asked questions
Is modulo the same as remainder?
They are closely related, but negative-input conventions can make a language remainder operator differ from the mathematical residue chosen.
Why is clock arithmetic modulo 12?
Positions repeat after twelve steps, so values differing by multiples of twelve share a position.
Can every number be divided modulo n?
No. Modular division requires the divisor to have an inverse modulo n, which occurs when the divisor and modulus are coprime.
