Suppose you roll an eight-sided die two times hoping to get two numbers whose sum is even. What is the sample space? How many favorable outcomes are there?
This is not a computer science question. I recommend you ask it in the Mathematics section.
Combinatorics is computer-sciency enough.
my bad
If you do a little number theory, you will realize that the sum of two even numbers and two odd numbers is always even. Therefore, you are looking at all the possibilities of obtaining two numbers of the same parity. The sample space of an 8-sided die rolled twice has a size of 64 outcomes. However, we are only interested in a specific subset of this sample space, namely, of numbers with the same parity. On your first roll, you can get anything, but you have two options: either an odd number or an even number. On your second roll, you are only interested in a number whose parity matches that of the first number. In the case of an 8-sided die, you will have 4 options. Hence, it is easy to see that you will have a sample space of 16 favorable outcomes.
Oh, yes, I forgot to add the even parity. Hence, 16+16.
Join our real-time social learning platform and learn together with your friends!