Simple statistics Combination/Permutation problem

Hello, I've recently joined this forum to get help in mathematics. I am going to be studying in an engineering field next year as an undergrad. Over the summer, I've taken up computer programming as a hobby and I'm having a hard time with some statistical programs I'm trying to make. Here is my simple problem:

How many different combinations of two numbers can add up to make 8? Each number can be no greater than 6.

This is exactly the probability of rolling an 8 when rolling two dice. I know that the answer to this question is 5, as in there are 5 different combinations of 2 numbers that will add up to equal 8. For example:

1. 2 + 6

2. 6 + 2

3. 3 + 5

4. 5 + 3

5. 4 + 4

Therefore, there is a 5/36 chance of rolling an 8 when rolling 2 dice with 6 faces each.

I want to extract some basic principle or formula out of this so that I can do the same thing with more dice and more or less faces on each die.

Thank you very much, I appreciate any responses.

(I'm not here just to leech on others. I plan contributing to the help threads where I'm qualified to actually help like calculus. )

Re: Simple statistics Combination/Permutation problem

Re: Simple statistics Combination/Permutation problem

Ah that's brilliant. I have no idea how that works but it works.

Thanks.

Re: Simple statistics Combination/Permutation problem

Is there a name for this procedure that I can Google in order to learn more on how it works?