585. Find the last non-zero digit of the product of all natural numbers from 1 to 40.
$\triangle$ First, let's find the last non-zero digit of the product $1 \cdot 2 \cdot 3 \cdot \ldots \cdot 10$. For this, we will remove the factors 10, 2, and 5 from the number. The remaining product is

$$
3 \cdot 4 \cdot 6 \cdot 7 \cdot 8 \cdot 9
$$

which, as is not difficult to calculate, ends with the digit 8.

For the same reason, each of the products

$$
11 \cdot 12 \cdot 13 \cdot \ldots \cdot 20, \quad 21 \cdot 22 \cdot 23 \cdot \ldots \cdot 30, \quad 31 \cdot 32 \cdot 33 \cdot \ldots \cdot 40
$$

has the last digit, different from zero, equal to 8. Then the last non-zero digit of the entire given product coincides with the last digit of the number

$$
8 \cdot 8 \cdot 8 \cdot 8=8^{4}=2^{12}=4096
$$

i.e., it is equal to 6.

Answer: 6.