Modular Arithmetic

Modular Arithmetic defines an operator called modulo operator, denoted as \(b \mod n\). The result will be the remainder \(a\) of \(b\) divided by \(n\). In modulo world, we will only concern about integers, \(\mathbb{Z}\).

Two numbers, \(a\) and \(b\) is said to be congruent, if \(a\) and \(b\) has the same remainder when divided by \(n\). For example, -10 and 12 is congruent if the modulo \(n\) is 11, since they have the same remainder, which is 1. This is denoted as the following equation:

$$ a \equiv b \mod n $$

Which could also be written as:

$$ a = qn + b $$

A congruence modulo has several properties, shown as below:

$$ \begin{align} a &\equiv b \mod n \text{ if } n | (a - b)\\ a &\equiv b \mod n \text{ implies } b \equiv a \mod n\\ a &\equiv b \mod n \text{ and } b \equiv c \mod n \text{ imply } a \equiv c \mod n \end{align} $$

We could get the next in line congruent residue by Modulo Reduction#. Based on this, we could do addition and multiplication, then modulo reduce the answer when doing Modular Arithmetic with any group of integers (that is Set# \(\mathbb{Z}_n = \{ 0, 1, \ldots, n - 1 \}\)). Additionally, the largest number in Modular Arithmetic (take note on doing addition and multiplication) would be \(n -1\) as it is a clock arithmetic. There are some properties of Modular Arithmetic that need to take note:

  • If \((a + b) = (a + c) \mod n\), then \(b = c \mod n\).
  • If \((a \cdot b) = (a \cdot c) \mod n\), then \(b = c \mod n\) if and only if \(a\) is relatively prime# to \(n\).

The following shows the example of Modulo 8:

+01234567
001234567
112345670
223456701
334567012
445670123
556701234
667012345
770123556

Note: The #inverse of the \(a\) could be found in the table by finding the matched row or column with value 0. For example, in the column \(4\), the value 0 appear in the row \(4\), thus \(4\) is the inverse of \(4\) in modulo 8.

Note: We could substitute \(a\) as \(a \mod n\) at any point.

Links to this page
#math