Lesson 3.6 · Write it
Times table row
A whole programPython or Java6 tests, 3 of them hidden
On a phone? Put the lines in order instead
Write a program that reads a number and prints its times table from 1 to 10, all on one line separated by spaces.
- Read one number on a single line.
- Print the products
n * 1,n * 2, ...,n * 10on a single line. - Separate the products with exactly one space.
The number is always a whole number from 1 to 1000. Your program is run several times. Only what it prints is checked.
Running Java here comes later. You can put this answer's lines in order instead. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.
Examples
Your program is run 6 times: the 3 examples below, and 3 hidden ones that check the rules above. Only what it prints is checked.
the 3 times table (rule 2)
You type
- typed: 3
It prints
3 6 9 12 15 18 21 24 27 30
the 1 times table (rule 2)
You type
- typed: 1
It prints
1 2 3 4 5 6 7 8 9 10
the 5 times table (rule 2)
You type
- typed: 5
It prints
5 10 15 20 25 30 35 40 45 50