5. Given a natural number $x=8^{n}-1$, where $n$ is a natural number. It is known that $x$ has exactly three distinct prime divisors, one of which is 31. Find $x$.
Answer: 32767.

Solution. One of the simple divisors of $x$ is obviously 7. First, let's prove that a number of the form $y=8^{k}-1$ is a power of 7 only in the case $k=1$. Indeed, for $k>1$, write $y=a b$, where $a=2^{k}-1, b=2^{2 k}+2^{k}+1$. Since

$$
b=2^{2 k}-1+2^{k}-1+3=a\left(2^{k}+2\right)+3
$$

the numbers $a$ and $b$ cannot both be divisible by 7, and $y$ will not be a power of 7.

The remainders of the powers of 8 when divided by 31 are $8,2,16,4,1$ and then repeat cyclically. Therefore, the divisibility of $x$ by 31 means that $n$ is a multiple of 5, i.e., $x=8^{5 m}-1$. Note also that $m$ is not divisible by 4, otherwise the divisors of $x$ will include 3, 5, and 7. For $m=1$, we get $x=32767=7 \cdot 31 \cdot 151$, which fits. Let's show that there are no solutions for $m>1$. By the formula for the sum of a geometric progression,

$$
x=p \cdot q, \quad \text{where } p=8^{m}-1, q=1+8^{m}+8^{2 m}+8^{3 m}+8^{4 m}
$$

Let's prove that the numbers $p$ and $q$ are coprime. Indeed, let the number $r$ divide $p$ and $q$. Then

$$
5=q-\left(8^{m}-1\right)-\left(8^{2 m}-1\right)-\left(8^{3 m}-1\right)-\left(8^{4 m}-1\right)
$$

Differences of the form $8^{k m}-1$ are divisible by $p$ and, therefore, by $r$. Thus, $r$ is a divisor of 5. But the remainders of $8^{m}$ when divided by 5 are $3,4,2,1$ and then repeat cyclically. Since $m$ is not a multiple of 4, the number $p$ is not divisible by 5, hence $r=1$. This means that $q$ is not divisible by 7, since $p \vdots$. Consider two cases.

1) $p$ is a multiple of 31. Then $m \vdots 5$, i.e., $m=5 k$. If $k=1$, then $p$ is divisible by 31 and 151. For $k>1$, we can apply the same reasoning to $p$ as to $x$. In both cases, $p$ will decompose into the product of two coprime numbers, neither of which are powers of 7. Taking into account the divisibility of $x$ by 7, we get that $x$ has at least four different prime divisors.
2) $q$ is a multiple of 31. Note that $p$ is divisible by 7, not being a power of 7, and $q$ is coprime with $p$. Then $q$ must be a power of 31, i.e., $q=31^{s}$. Transitioning to remainders when divided by 8, we get $1=(-1)^{s}$, hence $s$ is even. Moreover, the remainders of $31^{s}$ when divided by 7 for even $s$ are $2,4,1$ and then repeat cyclically. But the remainder of $q$ when divided by 7 is 5. Thus, $q$ cannot be a power of 31.