# How many 5-digit numbers can we assemble from the numbers 2,3,4,5,6,7,8,9 if the digits in each number can be repeated only once?

The wording here threw me off.

The answer given is $$8 \times 7 \times 6 \times 5 \times 4$$.

This suggests that "repeated once" means only used once. I interpreted "repeated once" to mean a digit $$2,...,9$$ can be used either once or twice (at most). Suppose I instead wish to answer the question that I interpreted it as. That is, I can use each digit once or twice but not more than twice.

I split this into 3 cases. The first is where no digit is repeated. The number of ways we can get this is $$8 \cdot7 \cdot6 \cdot5 \cdot4$$.

Now suppose we have one repeat then we have $$\left[\binom{5}{2} \cdot 8\right] \cdot 7 \cdot 6 \cdot 5$$ ways. That is, we can choose two slots out of five to put the first digit in.

Now suppose we have two repeats then we have $$\left[\binom{5}{2} \cdot 8\right] \cdot \left[\binom{3}{2} \cdot 7\right]\cdot 6$$. That is, we can choose two slots out of five to put the first digit in. Then we have to choose two of the remaining three slots to put the next digit in.

In summing the cases we get the result. Am I correct?

$$\left[\binom{5}{2} \cdot 8\right] \cdot \left[\binom{3}{2} \cdot 7\right]\cdot 6$$

The two repeated case is over counting, suppose the five seats are

$$\_~,~\_~,~\_~,~\_~,~\_~$$

First, you choose two seats, and fill in $$2$$

$$2~,~2~,~\_~,~\_~,~\_~$$

Next, you choose two seats, and fill in $$3$$

$$2~,~2~,~\_~,~3~,~3~$$

This is as the same as below:

First, you choose two seats, and fill in $$3$$

$$\_~,~\_~,~\_~,~3~,~3~$$

Next, you choose two seats, and fill in $$2$$

$$2~,~2~,~\_~,~3~,~3~$$

So you are over counting by twice. $$===========\text{Therefore, the correct answer is:}===========$$

$$8\cdot7\cdot6\cdot5\cdot4+\left[\binom{5}{2}\cdot8\cdot 7\cdot 6\cdot5\right]+\color{red}{\frac{1}2}\left[ \binom{5}{2}\cdot8\binom{3}{2}\cdot7\cdot6\right]=28560$$

Alternative method, no over counting risk, which is

"All cases" -" five repeated case" -" four repeated case"-" three repeated case"

$$8^5-\binom{5}{5}\cdot8-\binom{5}{4}\cdot8\cdot 7-\binom{5}{3}\cdot8\cdot7^2=28560$$