# Find the sum of all 4-digit numbers formed by using digits $0, 2, 3, 5$ - possible formula for competitive exam

Find the sum of all 4-digit numbers formed by using digits 0, 2, 3, 5 without repetition

There is a similar question in this site and Eric Tressler has provided a clear method to solve such questions. I have solved this question usingthe same approach and answer I got is $64440$

Today, came across a general formula in careerbless.(attaching it here)

According to this formula, I could solve this question as

$(4-1)!(0+2+3+5)(1111) - (4-2)!(0+2+3+5)(111)\\ =3!×10×1111-2!×10×111\\=64440$

Will this can formula be true in all cases where we find sum of all the n digit numbers formed by using n digit digits in which one digit is zero?

• It will only work where the given digits are all different, so in particular for $n\le10$. – almagest Jun 9 '16 at 13:18
• @I guess, given digits must be different, which is anyway given in the formula. (n distinct digits). Also when we takes a digit, we refer to 0-9 only right? – Kiran Jun 9 '16 at 13:20

Yes, it will work, but I would not suggest memorizing it. It is good to understand where it comes from. Let us start with the case that you have $n$ different digits, none of which are zero, and ask for the sum of all the $n$ digit numbers you can form. There are $n!$ numbers, one for each order of the digits. A specific digit $a$ appears in each position $(n-1)!$ times, so if we sum up its contribution we get $a \times (n-1)! \times (111\dots n \text{ times})$ Then summing over the digits gives the first term in your formula. Then if one of the digits is $0$, we need to account for the fact that we do not consider numbers starting with $0$ to be $n$ digit numbers. The sum of all the numbers starting with $0$ is the sum of the $n-1$ digit numbers formed from the remaining $n-1$ digits. We use the same formula as before, but decrease $n$ by $1$ and get the subtraction term.

If you do want to use a formula, it is better to put it in a self-explanatory form.

$n$ distinct digits form a $[n\;\; columns\times n!\;\;rows]$ phalanx,
and each column repeats each digit $\dfrac{n!}{n}$ times,

thus $\;\;\dfrac{n!}{n}\times\left[\text{ sum of digits}\right]\times[10^0 + 10^1 + ...10^{n-1}]$

Subtraction for numbers with a leading zero should be obvious