#567 · Loops · Beginner · 35 XP · about 6 min
A multiplication square is the chart on a classroom wall: row 3, column 4 holds 3 x 4 = 12. Write multiplication_square(n) that returns the square for the numbers 1 to n as a list of n rows, where each row is a list of n numbers.
The first row holds 1 times each number from 1 to n, the second row 2 times each number, and so on. For n = 0 return an empty list.
multiplication_square(3) # returns [[1, 2, 3], [2, 4, 6], [3, 6, 9]] multiplication_square(1) # returns [[1]] multiplication_square(0) # returns []
First solves only, ranked by stars and then time.