<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] Method $\#1:$
Observe that $$1+x\equiv-x^2\pmod{x^2+x+1}\text{  and }x^3\equiv1$$
$$\implies(1+x)^{3n+2}\equiv(-x^2)^{3n+2}\equiv(-1)^{3n+2}(x^3)^{2n+1}\cdot x\equiv(-1)^nx$$  as $3n+2\equiv n\pmod2$
Method $\#2:$
Observe that $$(1+x)^2\equiv x\pmod{x^2+x+1}\text{  and }x^3\equiv1$$
$$\implies(1+x)^{6n+5}=\{(1+x)^2\}^{3n+2}\cdot(1+x)\pmod{x^2+x+1}$$
$$\equiv x^{3n+2}\cdot(x+1)$$
$$\equiv(x^3)^n\cdot x^2(x+1)$$
$$\equiv1^n\cdot(x^3+x^2)$$
$$\equiv1+x^2\equiv-x$$
</s>