#P8723. Multiplication Table in Base P
Multiplication Table in Base P
Multiplication Table in Base P
The task is to generate a multiplication table in base P. In this problem, for a given base P, you need to print the multiplication table for numbers from 1 to P-1. Specifically, for each row i (where 1 ≤ i ≤ P-1), print the expressions for i x j for all j from 1 to i. Each expression should be in the format i*j=result
where result
is the product of i and j expressed in base P using digits 0-9.
The base conversion follows the formula: $$n = a_kP^k + a_{k-1}P^{k-1} + \dots + a_1P + a_0,$$ where each coefficient ai is a digit in the range [0, P-1].
Note: The order of multiplications in each row must follow the example. You must not change the order of operands.
For example, when P = 4, the output should be:
1*1=1 2*1=2 2*2=10 3*1=3 3*2=12 3*3=21
inputFormat
The input consists of a single integer P (2 ≤ P ≤ 10), which denotes the base for the multiplication table.
outputFormat
Print the multiplication table corresponding to base P. For each row i from 1 to P-1, output i expressions of the form i*j=result
, where the results are in base P. Print each row on a new line and separate expressions in the same row with a space.
sample
4
1*1=1
21=2 22=10
31=3 32=12 3*3=21
</p>