7.2. Petya wrote down all natural numbers from 1 to $n$ in a row on the board and counted the total number of digits written. It turned out to be 777. What is $n$?
Answer: 295. Solution: Since a total of 777 digits have been written, $n$ must be a three-digit number: indeed, in the case of a two-digit $n$, no more than $9+2 \cdot 90=189$ digits would have been written, and in the case of a four-digit (or more) number, more than $9+2 \cdot 90+3 \cdot 900=2889$ digits would have been written. Let $k$ be the number of three-digit numbers written ($k=n-99$). Then the total number of digits written is $9+2 \cdot 90+3 \cdot k$ $=777$. From this, $k=196$, and $n=k+99=295$.