The question is
If you were to write out 1,2,3,4….999,999. How many times would you
have to write the number 1? 1=1, 11=2, 1,111=4…and so on.
I know there are other ways to solve it, but I want to solve it using combinatorics and counting the number of ways to fill {XXX,XXX},{XX,XXX},…,{XX},{X} up with the digit 1.
This formula gives the correct answer but I'm not sure why. It seems unlikely that it would be a coincidence.
$\sum_{k=0}^6 \binom6k * k \space 9^{6-k}$ $ = 600,000$
I think this might be the reason this formula works. Begin by choosing k locations in
XXX,XXX
That's $\binom6k$ such as k=2
XX{X,X}XX
Then you multiply by the number of possibilities are each X in order, $9^4$.
So, why is there a k term?
Maybe this is the number of locations in {X,X}. Maybe the number of places to start filling with 1's.
Some work that seemed to be going in the correct direction. The number isn't too far off.
Treating it as a counting problem.
Again, counting the number of ways to fill XXX,XXX and then XX,XXX and X,XXX and etc.
Add
$\sum \binom6k * 9^{(6-k)}$ where k=1,…,6
$\sum \binom5k * 9^{(5-k)}$ where k=1,…5
$\sum \binom4k * 9^{(4-k)}$
$\sum \binom3k * 9^{(3-k)}$
$\sum \binom2k * 9^{(2-k)}$
$\sum \binom1k * 9^{(1-k)}$
=513240
Best Answer
Because it doesn't make an impact, let's try to count the number of times $1$ appears in the numbers from $0$ to $999999$.
We can create all $10^6$ numbers by considering all possible ways to assign a digit ($0$ to $9$) to each of the places in $XXXXXX$.
Since $1$ appears in each place $\frac{1}{10}$ of the time, we have that $1$ appears in the $k^\text{th}$ place exactly $\frac{10^6}{10}=10^5$ times.
Since there are $6$ places, we have that $1$ appears $\boxed{6\cdot 10^5}$ times in total.
P.S. There is also a nice sum identity that will help you in your approach $$\sum_{k=0}^n \binom{n}{k} kb^{n-k}=n(1+b)^{n-1}$$ You can substitute $n=6$ and $b=9$ to get your expression. To prove this, consider the binomial theorem, which states that $$f(a,b)=(a+b)^n=\sum_{k=0}^n \binom{n}{k} a^kb^{n-k}$$ Take the partial derivative wrt to $a$ to get $$\frac{\partial f(a,b)}{\partial a}=n(a+b)^{n-1}=\sum_{k=0}^n \binom{n}{k} k a^{k-1} b^{n-k}$$ Now plug in $a=1$ to get $$n(1+b)^{n-1}=\sum_{k=0}^n \binom{n}{k} k b^{n-k}$$