# Dice Combinations for a Particular Sum

Okay, here is a problem that has been bugging me:
Say that you have n dice that each have d sides, numbered 1 through m. How many different dice combinations, out of a total of n x d possible, are there where the sum of all of the dice is equal to r, for particular n, d, and r?
I'm not necessarily looking for a general solution, though one would be great. But I would like to at least be able to compute the answer for particular sets of input.

So far, I believe I have found that answering the main question is equivalent to determining the number of (rn) -combinations in a multiset with the form

{{k1, ... , kn}, {(k1, d−1), ... , (kn, d−1)}}

Basically, starting with each die at one and counting the number of ways I can build up to the total, r, without exceeding d in any of them.

I can find a solution where d = ∞ easily enough, but I am not sure how to eliminate the illegal combinations from that using Inclusion-Exclusion.

If someone could help me finish my solution or propose an alternate, easier solution, I would be very grateful.

Basically, if we are using two six-sided dice, then there are six ways to add up to seven:

1+6, 2+5, 3+4, 4+3, 5+2, and 6+1.

And five ways to add up to eight:

2+6, 3+5, 4+4, 5+3, and 6+8.

Et cetera.

Last edited: