4. Let $r_{n}$ denote the remainder of the division of $n$ by 3. Find the sequence of numbers $X_{n}$, which are the roots of the equation $(n+1) x^{r_{n}}-n(n+2) x^{r_{n+1}}+n^{2} x^{r_{n+2}}=0$ for any natural number $n$, and its limit is equal to 1.
4. Solution. Note that, since $r_{n}$ is the remainder of the division of $n$ by 3, it can take three different values: 0, 1, and 2.

Case 1. $n=3 k, k \in \square$, then $r_{n}=0, r_{n+1}=1, r_{n+2}=2$. The equation is: $n^{2} x^{2}-n(n+2) x+n+1=0$.

Its roots are

$x_{1, n}=\frac{1}{n}, \quad x_{2, n}=\frac{n+1}{n}$.

The condition of the problem ($x_{n} \rightarrow 1$ as $n \rightarrow \infty$) is satisfied only by $x_{2, n}$.

Case 2. $n=3 k+1, k \in \square \cup\{0\}$, then $r_{n}=1, r_{n+1}=2, r_{n+2}=0$. The equation is: $-n(n+2) x^{2}+(n+1) x+n^{2}=0$.

Its roots are

$x_{1, n}=\frac{n+1-\sqrt{4 n^{4}+8 n^{3}+n^{2}+2 n+1}}{2 n(n+2)}, \quad x_{2, n}=\frac{n+1+\sqrt{4 n^{4}+8 n^{3}+n^{2}+2 n+1}}{2 n(n+2)}$.

The condition of the problem ($x_{n} \rightarrow 1$ as $n \rightarrow \infty$) is satisfied only by $x_{2, n}$.

Case 3. $n=3 k+2, k \in \square \cup\{0\}$, then $r_{n}=2, r_{n+1}=0, r_{n+2}=1$. The equation is: $(n+1) x^{2}+n^{2} x-n(n+2)=0$.

Its roots are

$x_{1, n}=\frac{-n^{2}-\sqrt{n^{4}+4 n^{3}+12 n^{2}+8 n}}{2(n+1)}$

$x_{2, n}=\frac{-n^{2}+\sqrt{n^{4}+4 n^{3}+12 n^{2}+8 n}}{2(n+1)}=\frac{4 n^{3}+12 n^{2}+8 n}{2(n+1)\left(\sqrt{n^{4}+4 n^{3}+12 n^{2}+8 n}+n^{2}\right)}$.

The condition of the problem ($x_{n} \rightarrow 1$ as $n \rightarrow \infty$) is satisfied only by $x_{2, n}$.

Thus, the desired sequence is

$x_{n}=x_{2, n}=\left\{\begin{array}{cc}\frac{n+1}{n}, & n=3 k, k \in \square, \\ \frac{n+1+\sqrt{4 n^{4}+8 n^{3}+n^{2}+2 n+1}}{2 n(n+2)}, & n=3 k+1, k \in \square \cup\{0\}, \\ \frac{-n^{2}+\sqrt{n^{4}+4 n^{3}+12 n^{2}+8 n}}{2(n+1)}, & n=3 k+2, k \in \square \cup\{0\} .\end{array}\right.$