Forming n digit numbers out of 1,2,...,9 such that k digits can repeat

32 Views Asked by At

I came across following two problems:

(1) How many 5-digit numbers can be formed from the integers 1,2,…,9 with only one digit appearing twice?

(2) How many 5-digit numbers can be formed from the integers 1,2,…,9 with two digits appearing twice?

I solved (1) as follows:

(A): ${}^9P_5/2!=7560$
Since we have to permute 5 digits out of 9, out of which 2 are same.

But the given asnwer was:

(B): $9\times\binom{5}{2}\times 8\times 7\times 6=30240$
Since any one of 9 digits may repeat twice, out of 5 positions, 2 will be occupied by that digit. Number of ways to select these two positions = $\binom{5}{2}$ In remaining 3 positions, we have to put remaining digits which can be done in $8\times 7\times 8$ ways.

Then I tried solving (2) by approach (B):

(C): $9\times\binom{5}{2}\times 8\times \binom{3}{2} \times \frac{7}{2}=7560$
Devide by 2 follows because we count 33445 twice, one for 3 first and another for 4 first.

The given answer was:

(D): $\binom{9}{2}\times 7\times \frac{5!}{2!2!}=7560$
We can select two digits to be repeated out of 9 in $\binom{9}{2} $ ways. The last digit can be any of remaining 7. We can permute 5 digits out of which 2 are same and another 2 are same in $\frac{5!}{2!2!}$ ways.

So I tried solving (1) by approach (D):

(E): $9\times 8\times 7\times 6\times \frac{5!}{2!}=181440$

Now I am severely confused. I have following doubts:

D1: Why (A) is giving same value as (C) and (D)? Is (A) is third approach to solve (2) (first two approaches being (C) and (D)) instead of (1)? Or its just coincidence that (A) == (C) == (D)

D2: Why value of (E) (which follows approach of (D)) is not same as (B)?