The question is:
Find the sum of all the $5$-digit numbers that can be made using $0,0,1,2,3,4$.
My solution:
That is we can have two $0$s and one each of $1,2,3$ and $4$ as digits in our $5$-digit number.
What I did is this (I used principle of exclusion and inclusion):
I found the sum of all $5$-digit numbers using $0,0,1,2,3,4$, allowing the $0$s in the first place. This would be
$$5!(0+0+1+2+3+4)(1+10+10^2+10^3+10^4)=13,333,200$$
But many of the cases that is being counted in the above expression are actually either $4$-digit or $3$-digit numbers. To fix the overcounting problem of $3$-digit numbers, we subtract "sum of three-digit numbers using $1,2,3,4$" which is $$3!(1+2+3+4)(1+10+10^2)=6660$$ Next to fix the overcounting problem of $4$-digit numbers we subtract "sum of 4 digit numbers using $0,1,2,3,4$" which is equal to saying "(sum of $4$-digit numbers using $0,1,2,3,4$, allowing $0$ in the first place ) - (sum of three digit numbers using $1,2,3,4$). This is equal to $$4!(0+1+2+3+4)(1+10+10^2+10^3)-3!(1+2+3+4)(1+10+10^2)=259980$$ So the final answer should be $$13,333,200-6660-259980=13066560$$ But it's not. My book says its $6399960$ Please explain to me what went wrong......
My first question when looking at this problem is to ask "How many numbers are there possible?"
Pick a first digit, it can't be zero. Then, break into cases on if there are two zeroes or just one. Pick where the zero(es) go. Then from left-to-right pick what the remaining digits are.
$4\times (4\times 3\times 2\times 1 + \binom{4}{2}\times 3\times 2) = 240$
Now, of these $240$ outcomes, a quarter of them had a $1$ in the first place, a quarter had a $2$, etc...
Now, we ask the question, what is the probability that a $1$ is in the second place (the thousands digit). For this, let's run through the counting again. Pick the second digit to be the $1$, then pick the first digit. Break into cases on if two zeroes or not, and then left to right fill out the other places.
$1\times 3\times (3\times 2\times 1 + \binom{3}{2}\times 2) = 36$
Similarly, $36$ of the outcomes have a $2$ in the second place and so on... Similarly for the third, fourth, and fifth places.
Adding by organizing our thoughts with respect to the places rather than the entire numbers themselves... we can add all of the units digits together, all of the tensdigits, and so on giving:
$$60\times (1+2+3+4)\times 10000 + 36\times (1+2+3+4)\times 1111 = 6399960$$