permutations containing a specific digit Is there a formula to determine how many permutations of a certain set contain a specific value?
For example, of all 4-digit PIN numbers, how many contain the digit 2 (assuming there are 10,000 possible values, 0000-9999)?
If not, is there a better way to calculate this at scale? The best I can come up with is:
2XXX = 1000
X2XX = 990 (less the 10 included previously)
XX2X = 980
XXX2 = 970
total = 3940
 A: Count the number of permutations which do not contain your value (you have one less choice at each position)
A: Case 1: One digit is a 2. There are four possible places the 2 can be, and each of the other columns has 9 possible digits. There are $4 \times 9^3 = 2916$ choices with one 2.
Case 2: Two digits are 2s. There are $_4C_2 = 6$ ways to arrange the two 2s and nine choices for the other columns. There are $6 \times 9^2 = 486$ choices with two 2s.
Case 3: Three digits are 2s. There are 4 ways to arrange them and 9 choices for the remaining column. The number of choices with 3 2s is $4 \times 9 = 36$.
Case 4: All four digits are 2s, giving one additional choice.
The total number of choices that contain a 2 (or any given digit) is $2916 + 486 + 36 + 1 = 3439$.
A: It’s true that there are $1000$ PINs with a $2$ in the first digit, but the rest of your calculation goes astray. For instance, there are $9\cdot10\cdot10=900$ PINs of the form Y$2$XX with $\text{Y}\ne2$, not $990$: there are $9$ choices for the first digit, $10$ for the third, and $10$ for the fourth.
In a problem like this it’s easier to count the PINs that we don’t want and subtract that number from $10000$, the total number of PINs. The ones that we don’t want are the ones that contain no $2$, and it’s easy to see that there are $9^4$ of them: in each position we can choose one of the $9$ digits other than $2$. Thus, there are
$$10^4-9^4=10000-6561=3439$$
PINs that contain at least one $2$.
