Generate variables in multiple integral

I want to do a multiple integrate with n variables. When I change the value of n, I do not want to rewrite the variables in the integral manually like here:

fn[n_] := Product[x[i], {i, 1, n}];
n = 3;
Integrate[fn[n], {x[1], 0, 1}, {x[2], 0, 1}, {x[3], 0, 1}]


Instead of that, I want to generate the variables in the integral somehow, depending only on n. I have tried the following but it did not work out.

fn[n_] := Product[x[i], {i, 1, n}];
vars = Row[Table[{x[i], 0, 1}, {i, 1, n}], ","]
n = 3;
Integrate[fn[n], vars]


Could you point out how to do that?

• ”…but it did not work out.” can you, please, be more specific? While you got your answer (the key being some application of Sequence), one problem here is the attempted use of Row to create the structure that Sequence assists with generating. There would be many other ways to achieve the same thing, as the answer states…providing more detail/context would improve this question immensely! Apr 23 at 8:44

I am sure there are many ways to do this. Instead of

fn[n_] := Product[x[i], {i, 1, n}];
n = 3;
Integrate[fn[n], {x[1], 0, 1}, {x[2], 0, 1}, {x[3], 0, 1}]
(* 1/8 *)


You could do

n = 3
v = Array[x, n]
Integrate[Times @@ v, Sequence @@ ({#, 0, 1} & /@ v)]
(* 1/8 *)


And for more variables, you just need to change n value. Nothing else needs to change.