Last Updated: June 7, 2026
A multiplication table lists the products of a number with the integers from 1 to 10. The table of 5 is 5, 10, 15, 20, 25, 30, 35, 40, 45, 50. Return those ten products in order as an array.
The output always has exactly 10 elements: the first is n × 1, the last is n × 10. The size never depends on the value of n.
n can be negative → A negative n produces a table of negative products. The table of -3 is -3, -6, -9, ..., so the same multiplication logic works without any special handling for the sign.n can be zero → Every product of zero is zero, so the table of 0 is ten zeros. The general formula n × i already returns this, so no separate case is needed.-1000 <= n <= 1000 → The largest product is 1000 × 10 = 10000, which fits comfortably in a 32-bit int. There is no overflow concern.The value at step i is n × i, which maps directly to a loop from 1 to 10.
The one detail to track is the offset between counter and index: the product for n × 1 belongs at index 0, so counter i goes at index i - 1.
result of length 10.i from 1 to 10.result[i - 1] to n × i.result.Input:
Starting with i = 1, the product is 5 × 1 = 5, which goes at index 0. At i = 2, the product is 5 × 2 = 10 at index 1. The loop continues through i = 10, where 5 × 10 = 50 lands in the final slot. The array fills up one product at a time:
n.n. Ignoring the space used for the output, no extra memory is allocated.The multiplication operator does the work here, but multiplication is really repeated addition. Can we build the same table using addition alone?
Multiplying n by i is the same as adding n to itself i times, so n × 3 equals n + n + n. Keep a running total that starts at 0 and add n once per iteration. After the first addition the total is n, after the second 2n, and so on, so the total already equals n × i when it goes into the array.
This produces the same table as Approach 1 without the * operator.
result of length 10.sum to 0.i from 1 to 10.n to sum, so sum now equals n × i.sum at index i - 1.result.Input:
The running total starts at 0. On the first step it becomes 0 + 5 = 5, which equals 5 × 1 and goes at index 0. On the second step it becomes 5 + 5 = 10, matching 5 × 2, stored at index 1. Each step adds another 5, so the total climbs to 50 by the tenth step. The accumulated values form the table:
n.n. Beyond the output, only the single running total sum is stored.