← Unit 2 · all exercises
Saved in this browser only

Print a times table

Print the first five multiples of the number, one per line, in the form "3 x 1 = 3". Use a lower-case x with a space either side.

void table(int n)

Solution.java
Loading editor…
Results

Examples

  • table(3) → 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15
  • table(1) → 1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 1 x 5 = 5

There are also 2 hidden tests you can't see. Solve the problem, not the examples.