# Give the digits $0, 1, 2, 3, 4$, and $5$. How many four digit numbers can be formed if digits can be repeated and contain at least one digit $3$

Given the digits $0, 1, 2, 3, 4$, and $5$. How many four digit numbers can be formed if digits can be repeated and contain at least one digit $3$?

• Do you want to rule out numbers that begin with $0$? – user76568 Feb 25 '14 at 16:48

Hint: Count how many without the restriction and subtract the number with no $3$.

• I dont get what youre saying :/ – user131419 Feb 25 '14 at 16:15
• Robert is saying to figure out how many four digit numbers you can make using 0, 1, 2, 3, 4, and 5. You will end up with four digit numbers that might not have a 3 in them, like 1245 for instance. To fix this, find how many four digit numbers you can make using 0, 1, 2, 4, and 5. Then, subtract how many of these numbers you find from the original number you found. – josh Feb 25 '14 at 16:21

Generally, the number of strings of length $n$ with $m$ options per character is $m^n$.

So, the total number of four digit numbers, all digits being one of $\{0,1,2,3,4,5\}$ (other than the first which cannot be $0$) is: $$5 \cdot 6^3=1080$$

We don't want numbers that don't contain $3$ at all, and there are $4 \cdot 5^3=500$ of this kind.

So the total for $3$ appearing at least once is: $$5 \cdot 6^3 - 4 \cdot 5^3 = 580$$

• The 4-digit numbers cannot start with $0$. That is a red herring if I am not missing something obvious. – Hawk Feb 25 '14 at 18:11
• @Hawk a red herring..? – user76568 Feb 25 '14 at 18:21
• It is fine now. I think you have realised the mistake. – Hawk Feb 25 '14 at 18:22
• @Hawk the mistake was allowing the number to begin with $0$? – user76568 Feb 25 '14 at 18:23
• Yes, I meant that. – Hawk Feb 25 '14 at 18:24