Amount of odd numbers between $4000$ and $5000$ with distinct digits and ranking of $4579$ in this sequence

alternative-proofcombinatorics

A combinatorics question asks to compute the amount of odd numbers, with distinct digits, between $4000$ and $5000$. I computed this as
$$5 \times 8 \times 7 = 280.$$

The follow-up question asks to rank these numbers from small to large and to determine the spot the number $4579$ in this sequence.

To solve this, I made the distinction between several cases:

  • second digit is even (so 0 or 2)
  • second digit is odd (1 or 3, the case where the second digit is 5 I treated separatly)
  • second digit is 5, with some more distinction: third digit is striclty smaller than 7 and then the third digit equals seven.

This is very cumbersome, so I wondered if there is a more elegant way to do this (using the amount of such numbers for example?). The correct answer should be the 147th spot.

Best Answer

Working with numbers from $4600-5000$, if the second digit is even there are $1\times1\times7\times5=35$ ways. If the second digit is odd there are $1\times1\times7\times4=28$ ways. So we have $280-35-35-28-28=154$. Then there $7$ more such numbers to get to $4579$ and so $4579$ is in the $147$th position.