Let's determine the sum of the digits in the cube of a number consisting of $n$ nines.
Solution. A number consisting of $n$ nines can be written in the form $10^{n}-1$. The cube of this number is:

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

The decimal representation of this number is:

$$
\underbrace{99 \ldots 9}_{n-1} 7 \underbrace{00 \ldots 0}_{n-1} 2 \underbrace{99 \ldots 9}_{n}
$$

The sum of the digits in this number is:

$$
(n-1) \cdot 9+7+(n-1) \cdot 0+2+n \cdot 9=9 n-9+7+0+2+9 n=18 n
$$