I was thinking about the problem 'How many times does the digit $7$ appear in all numbers $0$ to $1,000,000$?". This is easy enough so the obvious extension is how many times does some $2$-digit number appear? For example
How many times does $37$ appear between $0$ to $1,000,000$?
For example: $437,009$ contains one $37$, $373,737$ contains three $37$s. How many total $37$s appear if we write the numbers down?
My initial thoughts is that the answer ought to have something to do with the number of $7$s that appear from $0$ to $100,000$ as it looks like there's a bijection (where you simply get rid of the $3$ from the $37$ in the 6 digit number to give you a $5$ digit number) but this doesn't work for a few reasons. I otherwise can't make progress. Perhaps it's a matter of considering cases; how many have one $37$ in them, how many have two $37$s in them, etc.
How about for $77$ (where something like $777$ would count as two $77$s)?
Thank you.
How many have $37$ as the final two digits ie $xxxx37$? How many have $xxx37x$? - well there are $10^4$ possibilities for the $x$. Count all the examples - you end up counting $x37x37$ twice, and $373737$ three times, as you seem to want.
You can do exactly the same with $77$ because $xxx777$ gets counted twice, $xx7777$ three times etc.