How many 4 digit number can be formed by using 1,2,3,4,5,6,7 if at least one digit is repeated My approach for this was selecting 4 numbers from which one is being repeated


$$\boxed{A}\boxed{B}\boxed{C}\boxed{A} $$
$$\boxed{A}\boxed{B}\boxed{A}\boxed{A} $$
$$\boxed{A}\boxed{A}\boxed{A}\boxed{A} $$
and permitting them which gives 7$C_4$×4!/2! +7$C_4$×4!/3!+7$C_4$×4!/4! Since 2,3,4 no. Are being repeated numbers are being repeated


What they have done is
$7^4$-7$P_4$ subtracting cases where all 4 no. Are different from total cases. I agree but what is the flaw in my method
 A: The quick way
$$7^4 - \left[\binom{7}{4} \times 4!\right].$$
The hard way:
$$S_1 + S_2 + S_3 + S_4.$$
$S_1 = 7 =$ # ways all 4 numbers the same.
$S_2 = 7 \times 6 \times 4 =$ # ways 3 numbers the same.
$S_3 = \binom{7}{2}\times\binom{4}{2} =$ # ways of having two pairs of numbers.
$S_4 = 7 \times \binom{6}{2} \times 4 \times 3 =$ # of ways of having 2 of one number and two other numbers.
A: You’ve miscounted all three of your types with repetitions. This is most obvious in the case of the $AAAA$ type: you counted $\binom74\cdot\frac{4!}{4!}=35$ of them, but there are clearly only $7$: $1111$, $2222$, $3333$, $4444$, $5555$, $6666$, and $7777$. For your $ABAA$ type you give a figure of $\binom74\cdot\frac{4!}{3!}=140$, but this is an underrestimate: there are $7$ ways to choose $A$, then $6$ ways to choose $B$, and finally $4$ possible places to put the $B$ digit, for a total of $7\cdot6\cdot4=168$ possibilities. For the $ABCA$ type you calculate $\binom74\cdot{4!}{2!}=420$; however, there are $7$ ways to choose the $A$ digit, then $\binom42=6$ ways to choose $2$ places for them, $6$ ways to choose the first of the $2$ remaining places, and $5$ ways to choose a digit for the one remaining place, for an actual total of $7\cdot6\cdot6\cdot5=1260$ numbers of this type.
The most obvious problem with your calculation is the binomial coefficient $\binom74$: that’s the number of ways to choose $4$ different digits from the set $\{0,1,2,3,4,5,6,7\}$, and for these types you’re choosing fewer than $4$ different digits. For the first type you’re actually choosing only $3$ different digits, and there are only $\binom73$ ways to do this. Then you have to choose which one of them is to appear twice; there are $3$ ways to do this. Then you can multiply by $\frac{4!}{2!}$ to get the correct figure of $1260$. Similarly, in your second type you’re choosing only $2$ different digits, something that can be done in $\binom72$ ways. Then you have $2$ ways to choose which one of those digits is used only once and $4$ ways to choose where to use it, for a total of $168$.
And as noted in the comments, you missed the $AABB$ type with $2$ distinct digits, each appearing twice. There are $7$ choices for the first digit, $3$ choices for the position of its mate, and $6$ choices for the other digit, for a total of $7\cdot3\cdot6=126$ possible numbers of this type. And sure enough, $7+168+1260+126=1561$.
