2. If $a^{2}+a+1=0$, determine the value of the expression

$$
a^{1987}+\frac{1}{a^{1987}}
$$
Solution. If $a^{2}+a+1=0$, then $a \neq 1$, so we multiply the given equation by $a-1$ to get $(a-1)\left(a^{2}+a+1\right)=0$, i.e., $a^{3}-1=0$, which means $a^{3}=1$. Therefore, $a^{1987}=\left(a^{3}\right)^{662} a=1^{662} a=1 \cdot a=a$, so

$$
a^{1987}+\frac{1}{a^{1987}}=a+\frac{1}{a}
$$

From the condition $a^{2}+a+1=0$, we sequentially obtain $a^{2}+1=-a$ and if we divide by $a$, we find $a+\frac{1}{a}=-1$. Finally,

$$
a^{1987}+\frac{1}{a^{1987}}=a+\frac{1}{a}=-1
$$