I'm learning Sedgewick's "Algorithms" and stuck at exercise 1.4.40, cited :
Develop an appropriate mathematical model describing the number of triples of N random int values that sum to 0, where the values are uniformly distributed between –M and M, where M is not small
I do find a close answer for this question : Sum of three numbers from unformly distributed set equals to zero However, I don't really understand the two key steps :
pick three values from $[−,]$ that sum to $0$ (this can be done in $3^2+3+1$. Finally we pick the values of the remaining $−3$ positions (can be done in $(2+1)^{−3}$ ways).
Can anyone help to give some more clues on this combinatorics solution ? Many Thanks!