How to factorize :
$$f(x)=x^n+x+1 \ \ \ \ \ \ : n=3k+2 ,k\in \mathbb{N}$$
And :
$$g(x)=x^n+x-1 \ \ \ \ \ \ : n=3k+2 ,k\in2m-1 \ \ \ , \ \ m\in\mathbb{N}$$
My try :
$$f(x)=x^n+x+1=x^{3k+2}+x+1$$
$$=(x^{3k+2}+x^{3k+1}+x^{3k})-(x^{3k+2}+x^{3k+1}+x^{3k})+(x+1)$$
Now what ?
$$x^{3k+2}+x+1=x^{3k+2}-x^2+x^2+x+1=x^2((x^3)^k-1)+x^2+x+1$$ and use $x^3-1=(x-1)(x^2+x+1)$.
For $n=6m-1$ we have $$x^n+x-1=x^n+x^2-x^2+x-1=x^2(x^{n-2}+1)-(x^2-x+1)$$ and use $x^3+1=(x+1)(x^2-x+1).$