The sum of all integers less than n with a zero
Here are some hints. First, as András suggests, it is easier to sum instead all integers without a zero, and then use the well-known formula $1+\cdots+n = n(n+1)/2$.

Let $S_n$ be the sum of zero-less numbers up to and excluding $n$, and let $T_k$ be the sum of zero-less numbers of width exactly $k$. We start by calculating $S_{10^k} = T_1 + \cdots + T_k$. We have
$$ \begin{align*}
T_1 &amp;= 1 + \cdots + 9 = 45, \\
T_2 &amp;= 11 + \cdots + 99 = (1 + \cdots + 9 + 10 + \cdots + 90)\cdot 9 = 45 \cdot 11 \cdot 9, \\
T_3 &amp;= 111 + \cdots + 999 = (1 + \cdots + 9 + 10 + \cdots + 90 + 100 + \cdots + 900)\cdot 81 \\ &amp;= 45 \cdot 111 \cdot 81.
\end{align*} $$
In general we get the formula
$$ T_k = 45 \cdot (1+10+\cdots+10^{k-1}) \cdot 9^{k-1} = 5 \cdot (10^k-1) \cdot 9^{k-1}, $$
from which it is easy to compute $S_{10^k}$:
$$ S_{10^k} = \frac{5}{9} \sum_{\ell=1}^k 90^k - \frac{5}{9} \sum_{\ell=1}^k 9^k = 50 \frac{90^k-1}{89} - 5 \frac{9^k-1}{8}. $$
For the general case, let's take as an example $n = 1234$. Zero-less numbers less than $1234$ come in the following forms:


Numbers less than $1000$: there are $1 \cdot S_{1000}$ of these.
Numbers of the form $1XYZ$ where $X&lt;2$: there are $1 \cdot S_{100}$ of these.
Numbers of the form $12YZ$ where $Y&lt;3$: there are $2 \cdot S_{10}$ of these.
Numbers of the form $123Z$ where $Z&lt;4$: there are $3 \cdot 1$ of these.


The general case is similar. Suppose $n = d_k \cdots d_0$, where none of the digits is zero. Then
$$ S_n = d_k S_{10^k} + (d_{k-1}-1) S_{10^{k-1}} + \cdots + (d_1-1) S_{10} + (d_0-1). $$
If one of the digits is zero, say $n = 1230456$, then we can replace $n$ with $1230000$, and use the same recipe as before, stopping at the first zero digit.