# How many four-digit odd numbers, all of digits different, can be formed from the digits 0 to 9, if there must be a 5 in the number?

How many four-digit odd numbers, all of digits different, can be formed from the digits 0 to 9, if there must be a 5 in the number?

I know that there are 4 different cases where 5 is in the number:

5 _ _ _

_ 5 _ _

_ _ 5 _

_ _ _ 5

The first digit cannot be 0, since it has to be a 4-digit number.

• Is it possible for 5 to appear more than once in the number? – John Molokach Jun 12 '15 at 20:07
• @JohnMolokach "all digits different" – Joffan Jun 12 '15 at 20:10

I would fill in the last number first and consider two cases: the last number is a $5$, and the last number is not a $5$.
This is the easy case, the remaining digits can be any distinct digits that are not $5$ (and do not begin with zero). This gives $8$ choices for the first number (not 5 and not 0), $8$ choices for the second number (not the first number, and not $5$) and $7$ choices for the third number (not the first two, and not $5$--the last). This gives $8\cdot 8\cdot 7=448 options. Case 2: The last number is not five. First, we will make sure the number is odd. To do that, the last digit must be either$1, 3, 5, 7,$or$9$. Since it is not$5$, we have$4$choices for the last digit. Now, let us fill in the first digit (since it cannot be zero). There are again$8$choices for the first digit (not the last digit and not zero). There are again,$8$choices for the second number and$7$for the third (for exactly the same reasons as mentioned before). We now have$4\cdot 8\cdot 8\cdot 7=1792$numbers. However some of these numbers didn't use a$5$. How many didn't use$5$? Let's count that and subtract. There are again$4$choices for the last number (since$5$wasn't an option there). Now there are only$7$choices for the first number: not$5$, not$0$, and not the last digit. Similarly, there are$7$choices for the second digit and$6$choices for the third digit. Thus, there are$7\cdot 7\cdot 6\cdot 4=1176$numbers that don't use$5$at all. Thus we have$1792-1162=616$good numbers. Combining case 1 and case 2 gives us$448+616=1064$four-digit, odd numbers with distinct digits and a$5$occurring exactly once. There are special conditions attached to the$\color{red}{\text{first}}$and$\color{blue}{\text{last}}$characters, so group into 3 cases: •$5$first: then for the remaining places there are (choosing the last digit first)$\color{blue}{4}\times 8\times 7 = 224$options •$5$second/third: then for the remaining places there are$\color{blue}{4}\times \color{red}{7}\times 7 = 196$options for each, so total of$2 \times 196 =392$for this case. •$5$last: then for the remaining places there are$\color{red}{8}\times 8\times 7 = 448$options Total options then are:$224+392+448=1064$. Another way to do this is to think of all the cases generally, and subtract all cases without any$5$s, because your question is essentially asking, "How many 4-digit odd numbers, all digits different, can we form where one of the digits is$5$?" So, the number of 4-digit odd numbers in general is$8\cdot8\cdot7\cdot5$. Explanation:$5$possible numbers in the last slot to make it odd,$8$in the first slot because it can't be what was in the last slot and it can't be$0$,$8$in the second slot (neither first nor last, but you can use$0$), and then$7$in the third slot. The number of 4-digit odd numbers without any$5$s is$7*7*5*4$. Explanation:$4$possible numbers in the last slot to make it odd, sans$5$. Follow same arguments as above. Final answer:$8\cdot8\cdot7\cdot5 - 7\cdot7\cdot5\cdot4=1064\$.