My question is the same as polynomial of degree n and its divisor except I want a solution that does not make use of complex numbers
Problem: Find all positive integers $n$ such that $x^2+x+1\mid (x+1)^n+x^n+1$
Using wolframalpha, I can see that a number of solutions work, such as $2,4,7$. I tried substituting various values of $x$ in and then working in specific mod cases, but this doesn't really seem to work because it only gives possible values, not 'actual' values. Polynomial long division here is also quite unwieldy...
Since $$(x+1)^6\equiv 1\mod (x^2+x+1)$$ and $$x^6\equiv 1\mod (x^2+x+1)$$ the exponent $n$ can be reduced modulo $6$. Inspection gives the solutions $2$ and $4$ in the interval $[1,6]$, hence the condition is satisfied if and only if $n\equiv \pm2\mod 6$. So exactly the even exponents $n$ not divisible by $3$ do the job.