Times table
Read a number n and print its times table from 1 to 10, one line each, in the form n x i = result.
For 3, the first line is 3 x 1 = 3.
Input
3
Expected output
3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30
Input
7
Expected output
7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 7 x 8 = 56 7 x 9 = 63 7 x 10 = 70
Show a hint
A for loop from 1 to 10, printing n, " x ", i, " = " and n * i.
Show a solution
Loading the editor…
Run the tests to check your solution.