For a positive integer modulus , the residue class of an integer is the equivalence classIt contains all integers in the same position of the repeating cycle. For example,The residue class is this whole infinite collection; its canonical representative is the least nonnegative residue. Euclidean division gives exactly one such representative in , so there are exactly residue classes. When , there is just one, .
Define addition and multiplication of residue classes byThese definitions must give the same answer whichever integers represent the classes. If and modulo , thenBoth differences are divisible by , proving that the operations are well-defined. For example, and , since . Replacing nine by gives the same answers with smaller intermediate integers.
With these operations the residue classes form the finite commutative ring , a quotient ring. It need not be a field: although neither factor is the zero class. These zero divisors explain why division requires a unit modulo n. Reducing after each multiplication is especially useful in modular exponentiation, where the unreduced powers can become enormous.
New to topics? Read the docs here!