# How many numbers with 6 digits can be formed with the digits 1,2,3,4,5 such that the digit 2 appears every time at least three times?

How many numbers with 6 digits can be formed with the digits $$1,2,3,4,5$$ such that the digit $$2$$ appears every time at least three times.

My try:

Total numbers: $$5^6$$

Numbers in which 2 doesn't appear: $$4^6$$

Numbers in which 2 appear once : $$6\cdot4^5$$

Numbers in which 2 appear twice : $$13\cdot4^4$$

So my result is: $$5^6-4^6- 6 \cdot4^5-13\cdot4^4=2057$$ but the right answer is $$1545$$ How solve it ?

• Hmm... $2057-1545=2\cdot4^4$ right? – drhab Jul 9 '19 at 9:07
• yes, that means that I lost 2*4^4 numbers – DaniVaja Jul 9 '19 at 9:10
• Hint: you can insert $2$ elements in $6$ slots in $\binom{6}{2}=15$ different ways – M.P Jul 9 '19 at 9:10
• So evidently you forgot $2$ possibilities. In how many ways can we select $2$ objects out of $6$? – drhab Jul 9 '19 at 9:11
• 6!/(2!*4!)=15 so I forgot 2 cases, thanks – DaniVaja Jul 9 '19 at 9:12

Hint: How did you get $$13$$ in $$13\cdot 4^4$$?
...or the other way around: $$\binom{6}{3}4^3 + \binom{6}{4}4^2 + \binom{6}{5}6^1 +1$$. Keep in mind $$\binom{6}{4} = \binom{6}{2}$$. It's a term longer, but gives you an opportunity to compute sm binomial coefficients.