<s>[INST] 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 !!!
 [/INST] 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$$
</s>