[Math] 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

combinationscombinatoricspermutations

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.

Best Answer

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$.

Case 1: Last number is five.

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.