Find the number of positive integers that satisfy both the following conditions: Each digit is a 1 or a 2 The sum of the digits is 8
We can solve this problem by using casework and counting the number of possibilities for each case.
Case 1: The number has one digit that is equal to 1 and the other digits are equal to 2. There are 8 ways to choose the position of the digit that is equal to 1 (it can be any of the 8 digits). Once we have chosen the position of the digit that is equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^7$ possibilities.
Case 2: The number has two digits that are equal to 1 and the other digits are equal to 2. There are $\binom{8}{2} = 28$ ways to choose the positions of the digits that are equal to 1. Once we have chosen the positions of the digits that are equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^6$ possibilities.
Case 3: The number has three digits that are equal to 1 and the other digits are equal to 2. There are $\binom{8}{3} = 56$ ways to choose the positions of the digits that are equal to 1. Once we have chosen the positions of the digits that are equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^5$ possibilities.
Case 4: The number has four digits that are equal to 1 and the other digits are equal to 2. There are $\binom{8}{4} = 70$ ways to choose the positions of the digits that are equal to 1. Once we have chosen the positions of the digits that are equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^4$ possibilities.
Case 5: The number has five digits that are equal to 1 and the other digits are equal to 2. There are $\binom{8}{5} = 56$ ways to choose the positions of the digits that are equal to 1. Once we have chosen the positions of the digits that are equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^3$ possibilities.
Case 6: The number has six digits that are equal to 1 and the other digits are equal to 2. There are $\binom{8}{6} = 28$ ways to choose the positions of the digits that are equal to 1. Once we have chosen the positions of the digits that are equal to 1, there are 2 possibilities for each of the other digits, for a total of $2^2$ possibilities.
Case 7: The number has seven digits that are equal to 1 and the other digit is equal to 2. There are 8 ways to choose the position of the digit that is equal to 2. Once we have chosen the position of the digit that is equal to 2, there are 2 possibilities for each of the other digits, for a total of $2^7$ possibilities.
Case 8: The number has eight digits that are equal to 2. There is only one possibility in this case.
Thus, the total number of positive integers that satisfy both conditions is:
2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^7 + 1 = 381.
2222 , 11222 , 12122 , 12212 , 12221 , 21122 , 21212 , 21221 , 22112 , 22121 , 22211 , 111122 , 111212 , 111221 , 112112 , 112121 , 112211 , 121112 , 121121 , 121211 , 122111 , 211112 , 211121 , 211211 , 212111 , 221111 , 1111112 , 1111121 , 1111211 , 1112111 , 1121111 , 1211111 , 2111111 , 11111111 , Total = 34 such integers.