# Number of permutations with conditions on sum of elements

I am trying to model game with dice. I am throwing three dice, sum up results on them. If result is equal or less than given number, that's a success, if not - failure. Probability function $p(n)$ is defined on $n$ from 3 to 18. I suspect it's recursive: $p(n) = p(n-1)$ + number of combinations (permutations?), elements of which sum to n. As I have a probability table, I can guess $p(3)=1/216;$ $p(4) = p(3) + 3/216;$ $p(5) = p(4) + 6/216$. My problem is that I can't understand, how to calculate for given n number of combinations (permutations?) which sum to given n. Anyone can give any advice on this?

Use generating functions[assuming distinct die, I have a method for identical die too!]: $$\text{Coefficient of }x^n\text{ in }\left(\sum_{k=1}^6x^k\right)^3$$ That would be in: $$\left(\frac{1-x^7}{1-x}\right)^3=(1-x^7)^3(1-x)^{-3}$$ I hope you can use the binomial theorem now? $$(a+b)^n=\sum_{k=0}^n \binom nk a^kb^{n-k}\\\binom nr=\binom{n+r-1}r\qquad(n<0)$$