Skip to content
ExamSpine

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.

  1. Read one number on a single line.
  2. Print the products n * 1, n * 2, ..., n * 10 on a single line.
  3. 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

    1. typed: 3

    It prints

    3 6 9 12 15 18 21 24 27 30
  • the 1 times table (rule 2)

    You type

    1. typed: 1

    It prints

    1 2 3 4 5 6 7 8 9 10
  • the 5 times table (rule 2)

    You type

    1. typed: 5

    It prints

    5 10 15 20 25 30 35 40 45 50
solution.pySolution.java