Your task is to create a good multiplication table for others to use. Given an integer \$n\$, generate a multiplication table that displays products up to \$n×n\$. You should start with \$2×2\$ as 1 times any number is itself and that is reflected in the row/column indices. Scientific notation and floating-points are NOT allowed. You must print every digit with no decimals (.00 or .00000034).
Formatting is a crucial component (after all, mutiplication tables are notorious for their formatting). The formatting criteria are listed below:
- At the top left corner or \$ \text{table}[0][0] \$, there will be a single number
1
. - Each row and column index will be \$n\$ digits + one whitespace.
- There is one row of hypens/dashes that span from the beginning of the table and ends at the last digit of the number who has the largest amount of digits in the rightmost column.
- There is 1 column of pipes
|
that start from the top of the multiplication table and ends at the \$n\$th row. This column of pipes should not get in the way of the row indices' formatting. - The values of the table should have its leftmost digit aligned with the leftmost digit of the column index.
- Between each value in each column, there should be one whitespace seperating the value. There will be NO newlines seperating each row.
Below is an example the covers all of the above points. Note: for brevity, the example table skips from 2 directly to 54, your actual program should include ALL digits from 2 to 54 and onwards to 654546.
1 | 2 54 3443 654546
-------------------------------------------------
2 | 4 108 6886 1309092
54 | 108 2916 185992 35345484
3443 | 6886 185992 11854249 2260487878
654546 | 1309092 35345484 2260487878 431052650116
- Observe how in the above table, the hypens take priority over the pipes.
- Notice how, no matter the size of the numbers, each column has at least 1 whitespace seperating it.
- The hypen row ends at the last digit of \$431052650116\$ NOT \$654546\$.
- Each column has its leftmost digit aligned with the leftmost digit of the column index (ex. the "6" in 6886 is aligned with the "2" in the column index).
- Refer to the above table when in doubt. Comment for any clarifications.
SAMPLE INPUT
5
SAMPLE OUTPUT
1 | 2 3 4 5
---------------
2 | 4 6 8 10
3 | 6 9 12 15
4 | 8 12 16 20
5 | 10 15 20 25
Constraints
You will possibly need unsigned 64-bit integers. $$ 2 \leq n \leq 10^9 $$