4. The record of a natural number $x$ in a base $r$ system ( $r \leqslant 70$ ) is obtained by $n$ repeated occurrences of a certain pair of digits, where $n$ is a natural number. It turns out that the $r$-ary representation of $x^{2}$ consists of $4 n$ ones. Find all pairs $(r, x)$ for which this is possible.
Answer: $\left(7,26_{7}\right)$.

Solution. Let $x=\overline{a b \ldots a b_{r}}$. Set $y=\overline{a b}_{r}$ and write the condition as

$$
\begin{aligned}
y^{2}\left(1+r^{2}+\ldots+r^{2(n-1)}\right)^{2}=1+r+\ldots+r^{4 n-1} & \Longleftrightarrow y^{2} \cdot \frac{\left(r^{2 n}-1\right)^{2}}{\left(r^{2}-1\right)^{2}}=\frac{r^{4 n}-1}{r-1} \Longleftrightarrow \\
& \Longleftrightarrow y^{2}\left(r^{2 n}-1\right)=(r+1)\left(r^{2}-1\right)\left(r^{2 n}+1\right)
\end{aligned}
$$

From this, it follows that $y^{2} \bmod r=1$, and also the equality

$$
r^{2 n}\left(y^{2}-(r+1)\left(r^{2}-1\right)\right)=y^{2}+(r+1)\left(r^{2}-1\right)
$$

Then $y^{2}-(r+1)\left(r^{2}-1\right)>0$ and

$$
\left(y^{2}-(r+1)\left(r^{2}-1\right)\right) \bmod r=\left(y^{2}+1\right) \bmod r=2 \bmod r \neq 1
$$

Therefore, $y^{2}-(r+1)\left(r^{2}-1\right) \geqslant 2$ and

$$
2 r^{2 n} \leqslant(r+1)\left(r^{2}-1\right)+y^{2} \leqslant(r+1)\left(r^{2}-1\right)+\left(r^{2}-1\right)^{2}=\left(r^{2}-1\right)\left(r^{2}+r\right)<2 r^{4}
$$

which is possible only when $n=1$. Thus,

$$
(a r+b)^{2}=(r+1)\left(r^{2}+1\right)
$$

Note that the numbers $r+1$ and $r^{2}+1$ cannot be coprime, otherwise $r^{2}+1$ would be a perfect square. Then from the equality $r^{2}+1=(r+1)(r-1)+2$ it follows that their greatest common divisor is 2. Therefore, $r$ is odd and

$$
\left(\frac{a r+b}{2}\right)^{2}=\frac{r+1}{2} \cdot \frac{r^{2}+1}{2}
$$

The fractions on the right side are coprime and must be perfect squares. In particular, $r=2 k^{2}-1$, and the condition $r \leqslant 70$ is satisfied only by $r \in\{7,17,31,49\}$. The last three options do not work, since the numbers $\frac{17^{2}+1}{2}=145, \frac{31^{2}+1}{2}=481$ and $\frac{49^{2}+1}{2}=1201$ are not perfect squares. Let $r=7$. Then

$$
y=a r+b=\sqrt{(r+1)\left(r^{2}+1\right)}=\sqrt{8 \cdot 50}=20=26_{7}
$$

from which $a=2$ and $b=6$. This works, since

$$
26_{7}^{2}=\left(30_{7}-1\right)^{2}=1200_{7}-60_{7}+1=1111_{7}
$$