Question from Katy, a teacher:
Using only the digits 0,3,4,5,6,and 7, how many distinct fourdigit numbers exist that are greater than 4002 and less than 6732?


Hi Katy.
Let's break it down into chunks. Clearly the valid numbers all start
with a 4, 5 or 6:
 If it starts with a 5, any following digits are allowed from the selection 0, 3, 4, 5, 6, 7 for the remaining three places (hundreds, tens, ones). There are 6 choices for each of the 3 places. That means 6^{3} distinct valid numbers starting with a 5.
 If it starts with a 4, then we have the same 6^{3} choices with only one exception: 4000 can be made with the right digits, but isn't greater than 4002. Therefore there are 6^{3}  1 distinct valid numbers starting with a 4.
 If it starts with a 6, it gets more complicated. It may start with a 60, 63, 64, 65, 66, or 67. Only the 67 needs special treatment, so let's put it aside for now. The others (there are 5 choices) can have any of the normal 6 digits in the tens and any of them in the ones column. That's 6^{2} for each of the 5 twodigit prefixes.
Now let's get back to the numbers starting with 67. In this case, it is easy to just list them and count them: 6700, 6703 6704 6705 6706 6707 6730. That's it: 7 distinct valid numbers starting with 67 which are less than 6732.
Finally, add them up to get the total:
[6^{3}] + [6^{3}  1] + [5 x 6^{2} + 7]
Hope this helps,
Stephen La Rocque.
