How many $4$-digit numbers can be formed using digits $0,1,…6$ such that it contains the digits $3$ and $5$

combinatoricspermutations

How many $4$-digit numbers can be formed using digits $0,1,…6$ such that it contains the digits $3$ and $5$?

My try:

All possible $4$-digit numbers $= 7 \cdot 7 \cdot 7 \cdot 6$

$4$-digits numbers NOT containing $3, 5 = 5 \cdot 5 \cdot 5 \cdot 4$

Answer= $7 \cdot 7 \cdot 7 \cdot 6-5 \cdot 5 \cdot 5 \cdot 4 =1558$

Is that OK ? If not, please explain my mistake.

Thank you.

Best Answer

Your answer is incorrect, because the negation of the statement that the positive integers includes the digits $3$ and $5$ is that it does not contain the digit $3$ or does not contain the digit $5$. What you subtracted is the number of $4$-digit positive integers that contain neither the digit $3$ nor the digit $5$. However, numbers such as $3460$ and $2145$ are also inadmissible.

How many $4$-digit positive integers can be formed using the digits $0, 1, 2, 3, 4, 5, 6$ with repetition contain the digits $3$ and $5$?

If there were no restrictions, the thousands place could be filled in six ways (since $0$ is excluded) and each of the three remaining places could be filled in seven ways (assuming repetition of digits is permitted). Hence, there are a total of $$6 \cdot 7 \cdot 7 \cdot 7$$ four-digit positive integers that can be formed using the digits $0, 1, 2, 3, 4, 5, 6$ with repetition.

From these, we must subtract those that do not contain the digits $3$ and $5$. Numbers that do not contain the digits $3$ and $5$ do not contain the digit $3$ or do not contain the digit $5$.

How many four-digit postive integers formed from the digits $0, 1, 2, 3, 4, 5, 6$ with repetition do not contain the digit $3$?

There are five ways to fill the thousands place (since neither $0$ nor $3$ is permitted) and six ways to fill each of the remaining places (since $3$ is not permitted). Hence, there are $$5 \cdot 6 \cdot 6 \cdot 6$$ such numbers.

By symmetry, there are also $$5 \cdot 6 \cdot 6 \cdot 6$$ four-digit positive integers formed from the digits $0, 1, 2, 3, 4, 5, 6$ with repetition that do not contain the digit $5$.

However, if we subtract those numbers that do not contain the digit $3$ and those numbers that do not contain the digit $5$ from the total, we will have subtracted those numbers that contain neither the digit $3$ nor the digit $5$ twice. We only want to subtract them once, so we must add them to the total.

How many four-digit positive integers formed from the digits $0, 1, 2, 3, 4, 5, 6$ with repetition contain neither the digit $3$ nor the digit $5$?

There are four ways to fill the thousands place (since neither $0$ nor $3$ nor $5$ is permitted) and five ways to fill each of the remaining three places (since neither $3$ nor $5$ is permitted). Hence, there are $$4 \cdot 5 \cdot 5 \cdot 5$$ such numbers.

By the Inclusion-Exclusion Principle, the number of positive four-digit positive integers formed from the digits $0, 1, 2, 3, 4, 5, 6$ with repetition that contain the digits $3$ and $5$ is $$6 \cdot 7 \cdot 7 \cdot 7 - 2 \cdot 5 \cdot 6 \cdot 6 \cdot + 4 \cdot 5 \cdot 5 \cdot 5$$

More formally, let's follow the suggestion of Nicolas FRANCOIS made in the comments. Let the universal set, $U$, be the set of four-digit positive integers that may be formed from the digits $0, 1, 2, 3, 4, 5, 6$ with repetition; let $A$ be the event that such a four-digit positive integer includes the digit $3$; let $B$ be the event that such a four-digit positive integer includes the digit $5$. What we wish to calculate is $$|A \cap B| = |U| - |(A \cap B)^C| = |U| - |A^C \cup B^C| = |U| - (|A^C| + |B^C| - |A^C \cap B^C|)$$ What we showed above is that \begin{align*} |U| & = 6 \cdot 7 \cdot 7 \cdot 7\\ |A^C| & = 5 \cdot 6 \cdot 6 \cdot 6\\ |B^C| & = 5 \cdot 6 \cdot 6 \cdot 6\\ |A^C \cap B^C| & = 4 \cdot 5 \cdot 5 \cdot 5 \end{align*} which gives \begin{align*} |A \cap B| & = |U| - |(A \cap B)^C|\\ & = |U| - |A^C \cup B^C|\\ & = |U| - (|A^C| + |B^C| - |A^C \cap B^C|)\\ & = |U| - |A^C| - |B^C| + |A^C \cap B^C|\\ & = 6 \cdot 7 \cdot 7 \cdot 7 - 5 \cdot 6 \cdot 6 \cdot 6 - 5 \cdot 6 \cdot 6 \cdot 6 + 4 \cdot 5 \cdot 5 \cdot 5\\ & = 6 \cdot 7 \cdot 7 \cdot 7 - 2 \cdot 5 \cdot 6 \cdot 6\cdot 6 + 4 \cdot 5 \cdot 5 \cdot 5 \end{align*}

How many $4$-digit positive integers can be formed using the digits $0, 1, 2, 3, 4, 5, 6$ without repetition contain the digits $3$ and $5$?

In this problem, either $3$ or $5$ is the leading digit or neither is.

$3$ or $5$ is the leading digit:

  1. Choose which of them is the leading digit.
  2. Choose the place occupied by whichever number in the set $\{3, 5\}$ that has not been used as the leading digit.
  3. Now that $3$ and $5$ have been placed, choose which of the remaining numbers occupies the first open place.
  4. Choose which of the remaining numbers fills the final open place.

There are $$2 \cdot 3 \cdot 5 \cdot 4$$ such numbers.

Neither $3$ nor $5$ is the leading digit:

  1. Choose which of the other non-zero digits occupies the thousands place.
  2. Choose which of the remaining places is occupied by the digit $3$.
  3. Choose which of the remaining places is occupied by the digit $5$.
  4. Choose which of the remaining digits fills the remaining place.

There are $$4 \cdot 3 \cdot 2 \cdot 4$$ such numbers.

Since these cases are mutually exclusive and exhaustive, the answer is found by adding the results for the two cases.