1

I am currently trying to create a function taht will sum over n variables, but I don't really know how ot implement it. It should look like this:

$$f[n]=\left(\frac{1}{6}\right)^n \sum _{x_1=1}^6\sum _{x_2=1}^6...\sum _{x_n=1}^6 x_1+x_2+...+x_n - \min(x_1,...,x_n)$$

Sadly I have no idea how I can tell mathematica to create the exact right amounts of variables and sums. Does anyone have an idea?

m0nhawk
  • 3,867
  • 1
  • 20
  • 35
Escapado
  • 13
  • 2

2 Answers2

2
f[n_] := 1/6^n Module[{xx = Array[x, n]},
                      Sum[Tr@xx - Min @@ xx, Evaluate[Sequence @@ ({#, 6} & /@ xx)]]]
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
2
f[n_] := Total[Total[#] - Min[#] & /@ Tuples[Range[6], n]]/6^n;
Per Alexandersson
  • 2,469
  • 15
  • 19