How many four digit numbers are there such that its digits strictly ascending?

I got this problem from a combo and probability book, and I found that all numbers have to be $\le 6789$, but certain numbers like $6788$ don't work. How do you find how many numbers there are without going through tons of casework? I would also like a solution to the problem applied to a n-digit number.


2 Answers 2


Let's choose 4 distinct numbers from the set of digits $\{1,2,3,4,5,6,7,8,9\}.$ (Note that $0$ cannot be included in this set.) For each choice, there is a unique way by which we can relabel those 4 numbers so that they are in ascending order. (For example, if we chose the numbers $1, 2, 3,\text{ and } 8,$ then the only way we can have them in ascending order would be $1238$ and nothing else.) So we'd have $\binom{9}{4}$ 4-digit numbers whose digits are strictly increasing. Using this logic, it wouldn't be too hard to extend it to any n-digit number as long as $n<10.$

  • $\begingroup$ Wow, nice method of abstract solution. $\endgroup$
    – Teoc
    Commented Sep 26, 2015 at 4:48

1234 to 6789

6790-1234 = 5556

Now get all possibilities of 0 out of these numbers. Then get rid of all number doubles, triples, quadruples. In the balance get rid of smaller numbers in sequence....

Total 126 numbers are there.

PHP program to do it:

$a = Array();
for ($i = 1234; $i < 6790; $i++) {
    $num = str_split((string)$i);

    for ($j=0; $j < 3; $j++) {
		$flag=($num[$j] < $num[$j+1]);
		if (!$flag) break;
		if ($j == 3) $a[] = $i;
	if ($flag) {
        echo $i . "<br>\n"; 
		$a[] = $i;
echo count($a);
  • 1
    $\begingroup$ Are you sure that a piece of cose is an appropriate answer to the question ? $\endgroup$ Commented Oct 17, 2016 at 10:08

You must log in to answer this question.

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