Question: How many four-digit numbers contain only the digits 1 and 2 and each of them at least once?

I have tried to do this question by listing all the possible values and have come to answer of 14. So, I was wondering whether there is a more efficient method instead of listing all the possible values.

Thank you.


closed as off-topic by Claude Leibovici, Lord_Farin, zarathustra, Daniel W. Farlow, Johanna Apr 12 '15 at 14:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Claude Leibovici, Daniel W. Farlow, Johanna
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ There are $2^4$ total 4-digit sequences containing only 1s or 2s (for each digit you have two choices). 2 of them are only 1's or only 2's. So subtract them off $\endgroup$ – David Peterson Apr 12 '15 at 6:01
  • $\begingroup$ As a rule of thumb, when a question has an accepted answer 22 minutes after it was asked... $\endgroup$ – Did Apr 12 '15 at 7:32
  • 1
    $\begingroup$ I'm voting to close this question, because unless it is reworded to apply to the general situation, it is not going to be of future relevance to anyone. $\endgroup$ – Lord_Farin Apr 12 '15 at 9:38

It's $2^4-2 = 14$. The first term indicates the way of choosing four independent digits, each one having two possibilities (being either $1$ or $2$); the $-2$ takes out $1111$ and $2222$.

  • $\begingroup$ Is the 2^4 like a formula I need to remember to solve questions like this? $\endgroup$ – anonymous Apr 12 '15 at 6:10

The number of 4-digit numbers with only digits $1$ and $2$ is $2^4=16$, and 2 of them are $1111$ and $2222$, which should be excluded.

  • $\begingroup$ How did you get 2^4? Is it some sort of formula? $\endgroup$ – anonymous Apr 12 '15 at 6:08
  • $\begingroup$ I suppose. If you have $n$ choices to make, and each one has $k$ possibilities, then there are $k$ ways to make the first choice, $k$ ways to make the second choice, etc. If they're all independent (as they are in this case), the number of ways to make all $n$ choices is $k$ times $k$ times ... $k$ ($n$ times), or $k^n$. $\endgroup$ – Brian Tung Apr 12 '15 at 6:13
  • $\begingroup$ Thank you for your support. $\endgroup$ – anonymous Apr 12 '15 at 6:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.