40. What is the smallest natural number by which the number 7 must be multiplied to obtain a number that consists only of nines?
$\triangle$ Let's find this number using division

$$
\text { 9999... } 7
$$

However, the quotient here is unknown, and the number of nines in the dividend is also unknown. We will perform the division by 7, appending nines to the dividend until the division is performed without a remainder for the first time. We get:

$$
\begin{array}{ll}
\frac{999999}{29} & \frac{7}{142857} \\
\frac{\frac{19}{\frac{59}{39}}}{\frac{39}{\frac{49}{0}}} & \\
&
\end{array}
$$

Answer: 142857.