# 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 !!!

• For e.g. 3 digit numbers you should adapt the factor "sum of all digits". You will get:$$2!×((1+2+3)+(1+2+4)+(1+3+4)+(2+3+4))×111$$Just discern the 4 options of choosing 3 digits out of 4. Apr 26, 2022 at 8:16

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$$

• Thanks ! This looks like a complete formula for $d$-digit numbers with $n$ distinct digits. If I am right, then this will work for the case where there is no repetition, right? Apr 26, 2022 at 8:34
• $10$ is fairly obviously the sum of the $1$ digit cases since $1+2+3+4=10$, and so on with the others Apr 26, 2022 at 8:41

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$$