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 ?
First, your arithmetic is wrong - you should get $x=0\implies B=1$ from the equation you are using.
Second your method is wrong. If you want to use the modulus you have $$(1+x)^{2015}=Q(x)(x^2+x+1) +Ax+B$$
If you set $x=0$ you get $1=Q(0)+B$ and since you don't know anything about $Q(x)$ yet, this tells you nothing useful.
If, however, you were to choose $x=\omega$ where $\omega^2+\omega+1=0$ and $\omega^3=1$ you would find that $$(1+\omega)^{2015}=A\omega+B$$And you would have $1+\omega=-\omega^2$ so that $(1+\omega)^{2015}=-\omega^{4030}$
And you can go on from there to solve the problem.