Yes, there is. I assume you are talking about base 10 - notice that in base 10, we can find the number of digits of a number using this formula:
$$ \left \lfloor \log{n} \right \rfloor - 1$$
For example:
$$ \left \lfloor \log_{10}(7521) \right \rfloor + 1 = 4$$
For simplicity we will denote:
$$\left \lfloor \log{n} \right \rfloor = c$$
Because we floor the logarithmic function, it looks as so:
- For values between $1-9$ it will output a $0$
- For values between $10 - 99$ it will output a $1$
- For values between $100 - 999$ it will output a $2$
- etc..
We can see the pattern here! for numbers with $d$ digits it will actually sum:
$$ 1 \cdot 90 + 2 \cdot 900 + \dots + d \cdot 9 \cdot 10^d$$
But what about the left-over? If we for example have $n = 1005$ then it will sum:
$$ 1 \cdot 90 + 2 \cdot 900 + ... \text{stop!}$$
What about $$ \left \lfloor 1000 \right \rfloor + \left \lfloor 1001 \right \rfloor + \dots + \left \lfloor 1005 \right \rfloor$$
Fortunately we can find this, by subtracting what we already found from the number ( not forgetting to include the last number:
$$ (n - 10^c + 1) \cdot (c)$$
Now what is left is to calculate what we already know.. if $n$ is given, we can know the number of digits so we can be sure it have $c-1$ digits right? ( if for example $n=7000$ then we can sure iterate $\left \lfloor \log{n} \right \rfloor - 1$ times) so we can sum:
$$ \sum_{i=1}^{c-1} 9 \cdot 10^i \cdot i = \frac{1}{9}( 9 \cdot 10^c \cdot c - 10( 10^c - 1)) $$
And so the final closed formula is:
$$ \frac{1}{9}( 9 \cdot 10^c \cdot c - 10( 10^c - 1)) + (n - 10^c + 1) \cdot (c)$$
Sum[Floor[Log[i]], {i, 1, n}]==1/2 (1 - n + 2 Log[Pochhammer[2, -1 + n]]) + I/(2 Pi)*Sum[Log[-j^(2 I Pi)], {j, 2, n}]
a Mathematica code. – Mariusz Iwaniuk Sep 04 '20 at 17:18