# How many ways can $7$ digits be selected from the set $S = \{1,2,3,4,5,6,7,8,9\}$ such that the greatest number in the selection is 9?

Our math teacher is currently teaching us probability and posed this question.

How many ways can $$7$$ digits be selected from the set $$S = \{1,2,3,4,5,6,7,8,9\}$$ such that the greatest number in the selection is 9? *Repetition is allowed

And I thought, well, since 9 should be the greatest number it should appear at least once. So, let us take 9 as our first digit. The rest of the 6 digits can be selected in $$9^6$$, because you can select any of the 9 digits and the greatest number would still be 9.

That would mean the answer would be $$9^6$$.

But, the solution that our teacher told us was to take all the possible selections and subtract the selections where 9 isn't present; i.e. the correct answer would be $$9^7 - 8^7$$.

So, where did I go wrong?

• Why do you assume that the first digit has to be $9$?
– user169852
Jul 16, 2021 at 9:27
• You took $9$ as the first digit but that's not necessary. Jul 16, 2021 at 9:27
• Because well, if the greatest digit is 9, then I presumed that 9 had to be selected at least once. That is why I took 9 as the first digit. And because it is a selection and order doesn't matter, I thought taking 9 as the first digit was ok Jul 16, 2021 at 9:30
• The teacher's solution implies that the order does matter. Otherwise the total number of possible selections would not be $9^7$.
– user169852
Jul 16, 2021 at 9:32
• Are you sure the question wasn't "How many 7-digit numbers can be selected..."? That would agree wth your teacher's answer. (By contrast, your $9^6$ answers the question "How many 7-digit numbers starting with $9$ can be selected...", which is different.) Jul 16, 2021 at 9:56

Try it with three digits from $$\{1,2\}$$ where the largest is $$2$$.

Your method would say the possibilities are $$211,212,221,222$$

but you would miss $$112,121,122$$.

Rather than your $$2^{3-1}=4$$ possibilities, there are the teacher's $$2^3-(2-1)^3=7$$ possibilities

• Actually, see these are supposed to be selections where order isn't supposed to matter, like combinations. So, umm 112 and 121 are supposed to be basically the same thing, That is why I took 9 as the first digit, assuming that order doesn't matter. Jul 16, 2021 at 9:51
• @AmandaRives In that case you are both wrong and the answer would be a smaller $3$ in my toy example for the patterns $222,221,211$, and ${9+7-2 \choose 7-1}=3003$ in your original question Jul 16, 2021 at 9:59
• how did you take the combinations to be 3003? Jul 16, 2021 at 10:06
• @AmandaRives Stars and bars on the six digits Jul 16, 2021 at 10:08
• Jul 16, 2021 at 10:12