Question: How to generate all vectors of length m with entries are 0's or 1's and entries sum to n then sum over these entries?

I need your help for this problem, please.

$\mathop  {\sum {...\sum }}\limits_{z_r \in {Q_{2}^{*}}}$ such that

$Q_{2}^{*}=((z_1,...,z_r):z_{j}=0,1,\sum_{j=1}^{r}z_{j}=\ell)$, where $\ell = 0, 1, . . . , r$.

For example. If r=3, $\ell=1$; then we are looking for triples with elements 0's or 1's and sum to 1 i.e. $Q_{2}^{*}={(0,0,1),(0,1,0),(1,0,0)}$. So we would like to sum over theses $z_r$'s.

I appreciate your help.

Please Wait...