# How many numbers with all different digits are between $1000$ and $4600$?

To answer this question my thought was to solve the problem by parts. So, first I counted how many numbers with all different digits there are less than $4000$:

For the first position (left to right) there are $4$ possibilities $(0,1,2,3)$. For the second position there are $9$, for the third they are $8$ and for the last we have $7$. Multiplied all possibilities, $4 \cdot9\cdot8\cdot7=2016$.

Then I counted how many numbers with all different digits there are less than $1000$. In this case one have at most $3$ positions. For the first position there are $10$ possibilities $(0,1,2,...,8,9)$, on the second position there are $9$ possibilities and the last position have $8$ possibilities. So, $10 \cdot9\cdot8=720$

Making the difference, $2016-720$, we get $1296$. Now I will counted the numbers with all different digits between $4000$ and $4600$:

In this part I will counted for less than $4600$, until $4599$. For the first position there is only one possibility. For the second position there are $5$, $(0,1,2,3,5)$. For the third position there are $8$ and the last position have $7$ possibilities. So $1 \cdot5\cdot8\cdot7=280$.

Finally there are $1296+280=1576$ numbers with all different digits between $1000$ and $4600$. Is my thought correct? Thanks

• Appears to be $1792$. sum(1 for i in xrange(1000,4601) if len(Counter(str(i)))==4) – Alexey Burdin Apr 30 '15 at 23:55
• You have a mistake in your counting I think: Looking in paragraph 2 if the first digit is 1,2, or 3 then you have 9 choices for the next digit, but if it is 0 you have 10 choices since 0 doesn't show up as a repeated digit in 90=0090 for example. You did the same thing in paragraph 3. – rVitale Apr 30 '15 at 23:58
• The count for $\lt 1000$ is not right. For $1000$ to $4000$, it would be better to say there are $3$ choices for the first digit, and $(9)(8)(7)$ for the rest, giving a total of $1512$. Your count of $280$ for $4000$ to $4600$ is correct. – André Nicolas Apr 30 '15 at 23:59

We consider two cases:

1. The positive integer is at least $1000$ but less than $4000$. We have three choices for the thousands digit ($1$, $2$, or $3$), nine choices for the hundreds digit (since we must exclude the thousands digit), eight choices for the tens digit (since we must exclude both the thousands digit and the hundreds digit), and seven choices for the units digit (since we must exclude the thousands digit, the hundreds digit, and the tens digit), giving a total of $3 \cdot 9 \cdot 8 \cdot 7 = 1512$ four digit positive integers with distinct digits less than $4000$.

2. The number is at least $4000$ and at most $4600$. As you determined, there is one choice for the thousands digit (namely, $4$), five choices for the hundreds digit ($0$, $1$, $2$, $3$, $5$), eight choices for the tens digit, and seven choices for the units digit, which yields $1 \cdot 5 \cdot 8 \cdot 7 = 280$ four digit positive integers with distinct digits between $4000$ and $4600$ inclusive.

Thus, there are $1512 + 280 = 1792$ positive integers $n$ satisfying the inequalities $1000 \leq n \leq 4600$ with distinct digits.

The numbers to be counted all are found in the range $10XX$ to $45XX$. There are $36$ such possible leading pairs (thousands and hundreds digits) in this range, but we eliminate $11, 22, 33,\text{ and }44$, leaving $32$ leading pairs of digits.

Each of these leading pairs leave 8 unused digits; the last digit pair (tens and units) can be selected from these in $8\times 7$ ways.

Initially consider 4 possibilities for the thousands; 6 possibilities for the hundreds as there are 7 digits 0 to 6; 8 possibilities for the tens; 7 possibilities for the units;

= 1,344 with a few numbers > 4600

The incorrect possibilities occur when we have 4 in the thousands and 6 in the hundreds. This will occur 8 x 7 times ie 56 times.

So the total number of distinct numbers is 1,344 – 56 = 1,288