Residue class (source code)

= Residue class
{title2=$[a]_m$}
{wiki}

For a positive <integer modulus> $m$, the residue class of an <integer> $a$ is the <equivalence class>
$$
[a]_m=\{a+km:k\in\mathbb Z\}=\{b\in\mathbb Z:b\equiv a\pmod m\}.
$$
It contains all <integers> in the same position of the repeating cycle. For example,
$$
[-1]_{12}=[11]_{12}=\{\ldots,-13,-1,11,23,35,\ldots\}.
$$
The <residue class> is this whole infinite collection; its canonical representative is the <least nonnegative residue>. <Euclidean division> gives exactly one such representative in $0,1,\ldots,m-1$, so there are exactly $m$ <residue classes>. When $m=1$, there is just one, $[0]_1=\mathbb Z$.

Define <addition> and <multiplication> of <residue classes> by
$$
[a]_m+[b]_m=[a+b]_m,\qquad [a]_m[b]_m=[ab]_m.
$$
These definitions must give the same answer whichever <integers> represent the classes. If $a'\equiv a$ and $b'\equiv b$ modulo $m$, then
$$
(a'+b')-(a+b)=(a'-a)+(b'-b),\qquad a'b'-ab=b'(a'-a)+a(b'-b).
$$
Both differences are divisible by $m$, proving that the operations are well-defined. For example, $[9]_{12}+[5]_{12}=[2]_{12}$ and $[9]_{12}[5]_{12}=[9]_{12}$, since $45=3\cdot12+9$. Replacing nine by $-3$ gives the same answers with smaller intermediate <integers>.

With these operations the <residue classes> form the finite <commutative ring> $\mathbb Z/m\mathbb Z$, a <quotient ring>. It need not be a <field>: $[6]_{12}[2]_{12}=[0]_{12}$ 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.