How to factorize :$f(x)=x^n+x+1 \ \ \ \ \ \ : n=3k+2 ,k\in \mathbb{N}$ 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 ?

Hint: evaluate $f(x)$ at $\omega$, where $\omega=e^{2\pi i/3}$, so $\omega^3=1$, and $\omega^2 + \omega + 1 = 0$.
