4. Given $x_{n}=\frac{1}{2}\left[(2+\sqrt{3})^{n}+(2-\sqrt{3})^{n}\right]$ $(n \in \mathbf{N}), x_{n}$ is a positive integer. Then the units digit of $x_{19981999}$ is ( ).
(A) 1
(B) 2
(C) 6
(D) 7
From equation (1), the unit digits of $x_{n} (n=1,2, \cdots)$ are $2,7,6,7,2,1,2,7,6, \cdots$.

Let $m\left(x_{n}\right)$ denote the unit digit of $x_{n}$, clearly $m\left(x_{n}\right)=$ $m\left(x_{n}+6 k\right)$, where $1 \leqslant n \leqslant 6, n k \in \mathbf{N}$,
$$
\begin{array}{l}
\therefore m\left(x_{19981999}\right)=m\left(x_{6 \times 3330333+1}\right) \\
=m\left(x_{1}\right)=2 .
\end{array}
$$
4. (B).

Let $a=2+\sqrt{3}, b=2-\sqrt{3}$, then
$$
\begin{array}{l}
a+b=4, a b=1, x_{n}=\frac{1}{2}\left(a^{n}+b^{n}\right), \\
\text { and }(a+b)\left(a^{n+1}+b^{n+1}\right) \\
\quad=\left(a^{n+2}+b^{n+2}\right)+a b\left(a^{n}+b^{n}\right), \\
4\left(a^{n+1}+b^{n+1}\right)=\left(a^{n+2}+b^{n+2}\right)+\left(a^{n}+b^{n}\right), \\
\therefore 4 x_{n+1}=x_{n+2}+x_{n}, \\
x_{n+2}=4 x_{n+1}-x_{n} .
\end{array}
$$

It is easy to get $x_{1}=2, x_{2}=7$.