I will use the fundamental principle of counting to solve this question.
Given the set of numbers, $D = \{2, 2, 3, 3, 3, 4, 4, 4, 4\}$.
Here, count(2's) = 2, count(3's) = 3, count(4's) = 4.
We are required to construct 4-digit numbers greater than 3000. For easy visualisation, we will use dashes on paper, _ _ _ _.
Case 1: Thousandth's place is 3.
Set, $D' = \{2, 2, 3, 3, 4, 4, 4, 4\}$.
Rest of the 3 places can be filled in $3 \times 3 \times 3$ ways provided we have 3 counts of the three unique digits, for filling each of the 3 places. But count(2's) = 2, count(3's) = 2 in the new set. Deficiency for each digit is 1. (Impossible numbers - 3222, 3333).
Therefore, ways to fill = $3 \times 3 \times 3 - (1+1) = 25$.
Case 2: Thousandth's place is 4.
Set, $D' = \{2, 2, 3, 3, 3, 4, 4, 4\}$.
Similarly, the deficiency is of only digit 2, which is 1 count. (Impossible number - 4222)
Therefore ways to fill = $3 \times 3 \times 3 - 1 = 26$.
Summing each case up, we get $26 + 25 = 51$.
Hope this helps.
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.
Best Answer
Hint: imagine writing all of them up, one below the other, as though you're about to add them up the way you (probably) learned in elementary school. How many have a 1 in the first column? A 2? A 3? What does that column sum to? Do this for each column, then put together the results.