count digits up to number n I am looking for the count of digits up to 1 million. Is there a formula for this? 
For example, the count of digits where $n = 10$ is $12$:
$0 (+1)$
$1 (+1)$
$2 (+1)$
$3 (+1)$
$4 (+1)$
$5 (+1)$
$6 (+1)$
$7 (+1)$
$8 (+1)$
$9 (+1)$
$10 (+2)$

$$ 1+ \sum_{i=1}^n \lfloor \log_{10} i + 1 \rfloor $$
where the $1$ infront is to account for the number $0$.
If you are looking for a compact form - that relieves you of summing the terms individually - you can aggregate terms:


*

*if $n<10$ then result $= n+1$

*if $10\le n < 100$ then result $= 10+2\cdot (n-9)$

*if $100\le n < 1000$ then result $= 190 + 3\cdot (n-90)$

*if $1000\le n < 10000$ then result $= 190 + 3*900 + 4\cdot (n-900) = 2890 + 4\cdot (n-900)$
and so on


In general: if $n$ has $m=\lfloor \log_{10} n +1 \rfloor$ digits, then the result is
$$ 10\cdot 1 + 90\cdot 2 + 900\cdot 3 + \dots + 9\cdot 10^{m-2}\cdot (m-1) + m\cdot (n-9\cdot 10^{m-2})$$
