Consider a n x n
multiplication table and replace each item with its remainder of division by n
. For example, here is a 6x6
table and its "modulo 6" structure: (The last column and row are ignored since both are null)
1 2 3 4 5 6 | 1 2 3 4 5
2 4 6 8 10 12 | 2 4 0 2 4
3 6 9 12 15 18 | 3 0 3 0 3
4 8 12 16 20 24 | 4 2 0 4 2
5 10 15 20 25 30 | 5 4 3 2 1
6 12 18 24 30 36 |
Now it is evident that the multiplication table modulo n is symmetric and can be reconstructed by one of its triangular quadrants:
1 2 3 4 5
4 0 2
3
Challenge
Given a positive integer N, print the upper quadrant of multiplication table modulo N. Assume that there is no restriction on the width of string in your output environment. The alignment of numbers shall be preserved. This means, the output should look like a part of a uniform product table, where the cells have equal widths. So for example, if we have a two-digit number in the table, all single-digit entries are separated by two spaces.
Rules
Standard code-golf rules apply.
Test cases
N = 1:
// no output is printed
N = 3:
1 2
N = 13:
1 2 3 4 5 6 7 8 9 10 11 12
4 6 8 10 12 1 3 5 7 9
9 12 2 5 8 11 1 4
3 7 11 2 6 10
12 4 9 1
10 3
+1
for a somewhat interesting challenge,-1
for the unnecessarily cumbersome output format. \$\endgroup\$