[Math] Number of permutations without leading zeroes.

combinatoricspermutations

Suppose I have a number $120$. I want to find the number of permutations its digits can have to form other numbers except the ones with leading zeroes.

For example, its permutations can be $120, 210, 201, 102, 012, 021$, which is $6$ or $n!$. However, I require $4$ (excluding the values with leading zeroes).

How can this be generalized to larger numbers?

Best Answer

Suppose you have $a_k$ $k$'s, for each digit $0\le k\le9$, and $a_0+a_1+\cdots+a_9=n$. Then the number of different $n$-digit numbers with no leading $0$'s that can be made with the specified digits is

$${n-1\choose a_0}{n-a_0\choose a_1}{n-a_0-a_1\choose a_2}\cdots{n-a_0-a_1-\cdots-a_{k-1}\choose a_k}\cdots{a_9\choose a_9}$$

For example, if you start with $00011377$, then $a_0=3$, $a_1=2$, $a_3=1$, and $a_7=2$ (and all other $a_k$'s are $0$), so we get $n=3+2+1+2=8$ and thus the number of $8$-digit numbers is

$${7\choose3}{8-3\choose2}{8-3-2\choose1}{8-3-2-1\choose2}={7\choose3}{5\choose2}{3\choose1}{2\choose2}=35\cdot10\cdot3\cdot1=1050$$

The key here is to place the $0$'s first. As long as they avoid the first position, they can go anywhere; once they're in place, the other digits go into any position still available, including the first position.

If you like, the formula can be rewritten more briefly as

$${n-1\choose a_0}{(n-a_0)!\over a_1!a_2!\cdots a_9!}$$

Related Question