Tables of Z/nZ

Addition, multiplication and power tables modulo n, with units, inverses, zero divisors and the group of units.

How it works

$\mathbb{Z}_n = \{0, 1, \dots, n - 1\}$ with addition and multiplication modulo $n$ is a ring. Its tables show the structure at a glance: in the addition table every row is a shift of the previous one, and the zeros pair each element with its negative.

In the multiplication table, the row of $a$ contains a $1$ exactly when $a$ has an inverse, that is when $\gcd(a, n) = 1$. These units form the group $\mathbb{Z}_n^{\times}$ with $\varphi(n)$ elements. Every other non-zero element is a zero divisor: $4 \cdot 3 \equiv 0 \pmod{12}$ although neither factor is $0$. When $n$ is prime there are no zero divisors, and $\mathbb{Z}_n$ is a field.

The power table shows the order of each unit, the first exponent $k$ with $a^k \equiv 1$. By Lagrange’s theorem it divides $\varphi(n)$, which proves Euler’s theorem $a^{\varphi(n)} \equiv 1$. If some unit has order exactly $\varphi(n)$, it is a primitive root and its powers run through all units; this happens only for $n = 2, 4, p^k$ and $2 p^k$. Diffie-Hellman and ElGamal work in such cyclic groups, with a large prime $p$.

Everything is calculated in your browser. Nothing you type leaves your device.