Find the sum of all the numbers less than $10000$ that can be formed using the digits $1, 2, 3$ and $4$ without repetition.

combinationscombinatoricscontest-mathpermutations

I was not able to solve this question on my own and then when I looked up on the web, I found that there is a formula somewhat related to this problem which states that

If all the possible $n$-digit numbers using $n$ distinct digits are
formed, the sum of all the numbers so formed is equal to $(n-1)! \times \text{Sum
of all the digits} \times \text{$111$… n times}$
.

And using this formula, I can find out the sum of all the $4$ digit numbers that are formed using $1, 2, 3$ and $4$ which turns out to be $6660$. But how can we extend the application of this formula for all the $3$ digits or $2$ digits numbers that can be formed using $1, 2, 3$ and $4$. Please help !!!

Thanks in advance !!!

Best Answer

The sum of such $4$-digit numbers is clearly not $6660$ since the two largest examples $4321$ and $4312$ add up to more than that; you should be multiplying by $1111$.

You might find it easier to work out the average value of the digits, i.e. $\frac{n+1}{2}$, and multiply the number of such numbers by this and by the values of their decimal position, so for your $n$ digits $1,2,\ldots,n$ this would give $n! \times \frac{n+1}{2} \times \frac{10^n-1}{10-1}$

For $d$-digit numbers with distinct digits drawn from $1,2,\ldots,n$ in base $b$ this would give $\frac{n!}{(n-d)!} \times \frac{n+1}{2} \times \frac{b^d-1}{b-1}$

so in total $$\sum\limits_{d=1}^n \frac{n!}{(n-d)!} \frac{n+1}{2} \frac{b^d-1}{b-1}$$

For $b=10$ and $n=4$ this gives $10+330+6660+66660=73660$