1
$\begingroup$

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?

$\endgroup$

marked as duplicate by ybeltukov, rhermans, Öskå, RunnyKine, m_goldberg Oct 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
$\begingroup$
f[n_] := Total[Total[#] - Min[#] & /@ Tuples[Range[6], n]]/6^n;
$\endgroup$
  • $\begingroup$ Thank you for your reply aswell. Your solution also works! $\endgroup$ – Escapado Oct 26 '14 at 20:29
2
$\begingroup$
f[n_] := 1/6^n Module[{xx = Array[x, n]},
                      Sum[Tr@xx - Min @@ xx, Evaluate[Sequence @@ ({#, 6} & /@ xx)]]]
$\endgroup$
  • $\begingroup$ Thank you. Your solution works perfectly and I understand what is going on. $\endgroup$ – Escapado Oct 26 '14 at 20:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.