# Summing over n variables [duplicate]

This question already has an answer here:

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?

## marked as duplicate by ybeltukov, rhermans, Öskå, RunnyKine, m_goldbergOct 26 '14 at 22:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

## 2 Answers

f[n_] := Total[Total[#] - Min[#] & /@ Tuples[Range, n]]/6^n;

• Thank you for your reply aswell. Your solution also works! – Escapado Oct 26 '14 at 20:29
f[n_] := 1/6^n Module[{xx = Array[x, n]},
Sum[Tr@xx - Min @@ xx, Evaluate[Sequence @@ ({#, 6} & /@ xx)]]]

• Thank you. Your solution works perfectly and I understand what is going on. – Escapado Oct 26 '14 at 20:28