<s>[INST] Remainder of $(1+x)^{2015}$ after division with $x^2+x+1$ 
Remainder of $(1+x)^{2015}$ after division with $x^2+x+1$

Is it correct if I consider the polynomial modulo $5$
$$(1+x)^{2015}=\sum\binom{2015}{n}x^n=1+2015x+2015\cdot1007x^2+\cdots+x^{2015}$$
RHS stays the same and then The remainder must be of the form $Ax+B$
$$x^{2015}+1\equiv Ax+B\pmod{1+x+x^2}$$
plug in $x=0\implies B=0$
plug in $x=1\implies A=-1\implies $ the remainder is $-x$
Is this a good way to solve the problem or were we lucky ?
 [/INST] Recall that $x^2+x+1=\Phi_3(x)$. If we set $\omega=\exp\left(\frac{2\pi i}{3}\right),\bar\omega=\left(\frac{2\pi i}{3}\right)$, we must have:
$$ (1+x)^{2015} = q(x)\cdot \Phi_3(x)+(Ax+B), \tag{1}$$
and evaluating the previous identity for $x\in\{\omega,\bar{\omega}\}$ we get:
$$ (1+\omega)^{2015} = A\omega+B,\quad (1+\bar\omega)^{2015} = A\bar\omega+B\tag{2}$$
but since $1+\omega=\exp\left(\frac{2\pi i}{6}\right)$ and $2015\equiv 5\pmod 6$, by setting $\zeta=\exp\left(\frac{2\pi i}{6}\right)$ we have that $(2)$ translates into:
$$ A\zeta^2 + B = \zeta^5,\quad A\zeta^4 + B = \zeta,\tag{3} $$
hence by Cramer's rule:
$$ A = \frac{\zeta^5-\zeta}{\zeta^2-\zeta^4}=-1, \qquad B=\frac{\zeta^3-\zeta^9}{\zeta^2-\zeta^4}=0.\tag{4} $$
</s>