Constructing Multiplication Table for Multiplication Modulo

When just multiplying in the reals I get:

$$\begin{array}{c|cccccc} \times & 1 & 5 & 7 & 11 & 13 & 17\\ \hline1 & 1 & 5 & 7 & 11 & 13 & 17\\ 5 & 5 & 25 & 35 & 55 & 65 & 85\\ 7 & 7 & 35 & 49 & 77 & 91 & 119\\ 11 & 11 & 55 & 77 & 121 & 143 & 187\\ 13 & 13 & 65 & 91 & 143 & 169 & 221\\ 17 & 17 & 85 & 119 & 187 & 221 & 289 \end{array} $$

Then $\mod 18$ we get

$$\begin{array}{c|cccccc} \times & 1 & 5 & 7 & 11 & 13 & 17\\ \hline 1 & 1 & 5 & 7 & 11 & 13 & 17\\ 5 & 5 & 7 & 17 & 1 & 11 & 13\\ 7 & 7 & 17 & 13 & 5 & 1 & 11\\ 11 & 11 & 1 & 5 & 13 & 17 & 7\\ 13 & 13 & 11 & 1 & 17 & 7 & 5\\ 17 & 17 & 13 & 11 & 7 & 5 & 1 \end{array}$$

So only the $5$ on the bottom left is wrong, this should be $11$. As it is a commutative group, you should have a symmetry relative to the diagonal, this would provide a quick way that finds this error.


Calculating these things are really neat to do in for instance Matlab / Octave.

Two lines:

ps = [1,5,7,11,13,17];

table = mod(ps'*ps,18)

First line defines the numbers as a row-vector.

Second line does outer product the vector with itself followed by an element-wise modulo.

My output is $$\text{table} = \left[\begin{array}{cccccc} 1&5&7&11&13&17\\ 5&7&17&1&11&13\\ 7&17&13&5&1&11\\ 11&1&5&13&17&7\\ 13&11&1&17&7&5\\ 17&13&11&7&5&1 \end{array}\right]$$