TITLE: Number of 5 digit numbers $< 40,000$
QUESTION [6 upvotes]: The numbers to be used are : 2, 3, 4, 4, 5
The way I approached this is: 
Total number of combinations possible is :
$$\frac{5!}{2!}$$
Total number of combinations starting with 4 :
$$4!$$
Total number of combinations starting with 5 :
$$\frac{4!}{2!}$$
$\therefore$ the total number of numbers $<$ 40,000 :
$$\frac{5!}{2!}-\Big(4!+\frac{4!}{2!}\Big)$$
I came across with this question and I don't have access to the solution.
I'm not confident if this is correct.

REPLY [9 votes]: To double-check the answer, you can use brute force:
$ python
>>> sum(sorted(str(x)) == sorted(str(23445)) for x in range(40000))
24