# What does problem statement mean by “using the Table function”? [closed]

Can you help me on the following question?

Generate the list

{{0}, {0, 2}, {0, 2, 4}, {0, 2, 4, 6}, {0, 2, 4, 6, 8}}


using the Table function.

Here is a simple way to generate it:

A = {0, 2, 4, 6, 8}
list1 =
{{A[]},
{A[], A[]},
{A[], A[], A[]},
{A[], A[], A[], A[]},
{A[], A[], A[], A[], A[]}}


but what does it mean by using the Table function ???

• I guess, the point is to automate the process so that one can also generate {{0},{0,2},{0,2,4},{0,2,4,6},{0,2,4,6,8}, ..., {0,2,4,..., 1000}}. Table allows you to do that if you identify the pattern of the sequence. – Henrik Schumacher Oct 29 at 13:17
• Try: i = 0; NestList[Append[#, ++i 2] &, {0}, 5] – Daniel Huber Oct 29 at 13:22
• Table lets you automatically generate lists as some parameter (or parameters) range over some values. So for example, Table[n^2, {n, 2, 6}] gives you a list of the values n^2 for n starting at 2 and going up to 6, i.e. {4,9,16,25,36}. You can also iniclude a step size, so that it increases the value of n in steps of that size, as Table[n^2, {n, 2, 11, 3}] for example, which gives n^2 for n starting at 2 and increasing in steps of size 3 until it hits 11, so that n equals 2, 5, 8, 11. – thorimur Oct 29 at 13:29
• You can also use multiple parameters, which will create nested tables, as in Table[n^k, {n,1,5},{k,0,3}], which will create {{1, 1, 1, 1}, {1, 2, 4, 8}, {1, 3, 9, 27}, {1, 4, 16, 64}, {1, 5, 25, 125}}. The order in which you provide the parameters determines which list is "inside"—try switching them and see what you get! – thorimur Oct 29 at 13:32
• Also note that you can browse the documentation here: reference.wolfram.com/language . For Table in particular, check out reference.wolfram.com/language/ref/Table.html?q=Table . Your Mathematica copy should also provide a "help" button in the top right of each window, and clicking on that will bring you to this documentation (but inside of mathematica, so that you can actually play with it as a notebook!) – thorimur Oct 29 at 13:32

You are probably expected to use Table like this:

A = {0, 2, 4, 6, 8};
Table[A[[;; i]], {i, Length[A]}]

{{0}, {0, 2}, {0, 2, 4}, {0, 2, 4, 6}, {0, 2, 4, 6, 8}}


Or in some equivalent way such as:

 Table[i, {k, A}, {i, 0, k, 2}]

Table[2 Table[i, {i, 0, k}], {k, 0, 4}]

(* {{0}, {0, 2}, {0, 2, 4}, {0, 2, 4, 6}, {0, 2, 4, 6, 8}} *)
`