Michael F. answered 07/25/22
PhD in Mat with 30+ Years of Teaching Experience in Math and Comp Sci
We assume that "3 of the digits are 7" means "exactly 2 of the digits are 7" and "2 of the digits are 2" means "exactly 2 of the digits are 2." We also assume that the 5-digit numbers run from 00000 to 99999 ..
Notation:
C(a,b) will mean "a choose b", the number of b-element subsets of a set with a elements C(a,b) is only nonzero if a and b are integers with 0 <= b <= a.
For any finite set X, let n(X) be the number of elements of X.
For two sets X and Y, X U Y is the union of X and Y, and X & Y is the intersection of X and Y.
Let S be the set of 5-digit numbers for which three of the digits are 7 and let T be the set of 5-digit numbers for which two of the digits are 2. Then we want to compute n(S U T), which is n(S) + n(T) - n(S & T).
Now n(S) is:
the number of ways to choose three digit positions from 1 to 5 to place three 7's
times
the number of ways to choose two (possibly equal) non-7' digits to place in the other two positions,
which is
C(5,3) = 10
times
9 x 9 .
So n(S) = 810
And n(T) is:
the number of ways to choose 2 digit positions from 1 to 5 to place two 2's
times
the number of ways to choose three non-two digits (repeating digits allowed) to place into the other three positions.
which is
C(5,2)
times
9 x 9 x 9 ,
So n(T) = 10 x 9 x 9 x 9 = 7,290.
And n(S & T) is the number of ways of placing the two 2 digits. The other digits must be 7's. That's C(5,2)=10.
So C(S U T) = 810 + 7,290 - 10 = 8,090 is the number of 5-digit numbers with three 7's or two 2's.