Calculate how many integers between $0$ to $9999$ that has the digits $2,5,8$. That is integers that has each of the three numbers at least once.

This is similar to How many numbers between $0$ and $9999$ have either of the digits $2,5,8$ at least once - Check my answer but mine is quite different.

My question is how do you calculate it by the 'straight forward' method ?

I have a proposed solution:

If the last digit is not one of the three then we have: $3!\cdot8$ possibilities.

If the last digit is one of them, we have $(3\cdot3!)/2$ we divide by two for symmetry (2258 is counted twice for example).

In total we get: 57 such integers.


2 Answers 2


No, with four different digits there are $7\times4!=168$ possibilities; with one of those three digits doubled there are $3\times4!/2!=36$ possibilities. That's $204$ in all.

  • $\begingroup$ Why there $4!$ ? You're arranging three digits not four... $\endgroup$
    – GinKin
    Commented Feb 4, 2014 at 18:07
  • $\begingroup$ One is adding one new digit to make four (in $7$ ways) then there are four digits to permute. $\endgroup$ Commented Feb 4, 2014 at 18:09

There are two cases: $2,5,8$ exactly once, and one of $2,5,8$ repeated.

For the first case, place the $2,5,8$ in the number, and then pick the last non-$(2,5,8)$ number to put in the last open space. This gives $4 \cdot 3 \cdot 2 \cdot 7 = 168$ numbers.

For the second case, pick the digit that is duplicated, and pick the two slots it goes in. Then place one of the non-duplicated digits, and place the other. This is $3 \cdot 6 \cdot 2 = 36$ possibilities.

So the total is $204$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .