a) How many 1-digit, 2-digit, 3-digit, and generally $n$-digit numbers are there?

b) How many digits do we need if we want to write down every natural number from 1 to $10^{n}$ (not including $10^{n}$)?
a) The task clearly concerns the positive integers. Among these, there are 9 single-digit numbers. The number of two-digit numbers can be obtained by subtracting the number of single-digit numbers from the total number of integers between 1 and 99, so there are 90 two-digit numbers. Similarly, the number of three-digit natural numbers is $999-99=900$. Since the last $(n-1)$-digit number is $10^{n-1}-1$, and the last $n$-digit number is $10^{n}-1$, the number of $n$-digit positive integers is the difference between these two:

$$
10^{n}-1-\left(10^{n-1}-1\right)=10^{n}-10^{n-1}=10^{n-1}(10-1)=9 \cdot 10^{n-1}
$$

b) The number of digits required to write the $n$-digit numbers can be obtained by multiplying $n$ by the number of $n$-digit numbers, $9 \cdot 10^{n-1}$. Thus, the number of digits required to write the numbers from 1 to $10^{n}$ (1, 2, 3, ..., n digits) is:

$$
S_{n}=1 \cdot 9+2 \cdot 9 \cdot 10+3 \cdot 9 \cdot 10^{2}+\ldots+n \cdot 9 \cdot 10^{n-1}
$$

With this, we have essentially solved the problem. We can also express the sum in a closed form. In part a), we already saw that the number of $n$-digit numbers is $9 \cdot 10^{n-1}$, which can also be written as $10^{n}-10^{n-1}$.

The desired sum, based on this, is:

$$
S_{n}=1\left(10^{1}-10^{0}\right)+2\left(10^{2}-10^{1}\right)+3\left(10^{3}-10^{2}\right)+\ldots+n\left(10^{n}-10^{n-1}\right)
$$

Let's expand the parentheses and combine the equal powers of 10:

$$
\begin{aligned}
S_{n}= & -10^{0}+(1-2) 10^{1}+(2-3) 10^{2}+\ldots+(n-1-n) 10^{n-1}+ \\
& +n \cdot 10^{n}=n \cdot 10^{n}-\left(10^{0}+10^{1}+10^{2}+\ldots+10^{n-1}\right)
\end{aligned}
$$

The part in parentheses is a geometric series with $n$ terms, and using the sum formula:

$$
S_{n}=n \cdot 10^{n}-\frac{10^{n}-1}{9}
$$

Thus, we have also expressed the sum in a closed form.