Find the sum of all the numbers less than $10000$ that can be formed using the digits $1, 2, 3$ and $4$ without repetition. 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 !!!
 A: 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$
A: Let's do some case work.
One-digit numbers:  There are four such numbers: $1, 2, 3, 4$.  They add to $10$.
Two-digit numbers:  Since repetition is not permitted, there are four ways to choose the tens digit and three ways to choose the units digit.  Hence, there are $4 \cdot 3 = 12$ such numbers.  By symmetry, each of the digits $1, 2, 3, 4$ must appear in each position $12/4 = 3$ times.  Hence, the sum of the two-digit numbers which can be formed from the digits $1, 2, 3, 4$ without repetition is
$$\frac{1}{4} \cdot 4 \cdot 3 \cdot (1 + 2 + 3 + 4)(10 + 1) = 330$$
Three-digit numbers:  Since repetition is not permitted, for each of the four choices for the hundreds digit, there are three choices for the tens digit, and two choices for the units digit.  Hence, there are $4 \cdot 3 \cdot 2 = 24$ such numbers.  By symmetry, each of the digits $1, 2, 3, 4$ must appear in each position $24/4 = 6$ times.  Hence, the sum of the three-digit numbers which can be formed from the digits $1, 2, 3, 4$ without repetition is
$$\frac{1}{4} \cdot 4 \cdot 3 \cdot 2 \cdot (1 + 2 + 3 + 4)(100 + 10 + 1) = 6660$$
Four-digit numbers:  Since repetition is not permitted, for each of the four choices for the thousands digit, there are three choices for the hundreds digit, two choices for the tens digit, and one choice for the units digit.  Hence, there are $4 \cdot 3 \cdot 2 \cdot 1 = 24$ such numbers.  By symmetry, each of the digits $1, 2, 3, 4$ must appear in each position $24/4 = 6$ times.  Hence, the sum of the four-digit numbers which can be formed from the digits $1, 2, 3, 4$ without repetition is
$$\frac{1}{4} \cdot 4 \cdot 3 \cdot 2 \cdot 1 \cdot (1 + 2 + 3 + 4)(1000 + 100 + 10 + 1) = 66~660$$
Total:  Since the four cases are mutually exclusive and exhaustive, the sum of all the numbers that can be formed using the digits $1, 2, 3,$ and $4$ without repetition is
$$10 + 330 + 6660 + 66660 = 73660$$
