Why $x^{p^n}-x+1$ is irreducible in ${\mathbb{F}_p}$ only when $n=1$ or $n=p=2$

I have a question, I think it concerns with field theory.

Why the polynomial $$x^{p^n}-x+1$$ is irreducible in ${\mathbb{F}_p}$ only when $n=1$ or $n=p=2$?

Thanks in advance. It bothers me for several days.

Solutions Collecting From Web of "Why $x^{p^n}-x+1$ is irreducible in ${\mathbb{F}_p}$ only when $n=1$ or $n=p=2$"

We will use fairly liberally the result that if $q(x)\in\mathbb F_p[x]$ is irreducible, then, for any $k$, $q(x)\mid x^{p^k}-x$ if and only if $\deg q\mid k$.

If $q_n(x)=x^{p^n}-x+1$ is irreducible, then there is a automorphism, $\phi$ of the field $\mathbb F_p[x]/\left<q_n(x)\right>$ which sends $\bar x$ to $\bar x-1$, namely:


for any element $\alpha$. (Where $\bar x$ is the image of $x$ from $\mathbb F_p[x]$ in this field.)

Then, $\phi(\bar x)=\bar x^{p^n}=\bar x-1$. So that automorphism must have order $p$: $\phi^p = 1$, the identity automorphism.

Now, $\phi^k(\alpha)=\alpha^{p^{kn}}$, so, in particular, $\bar x=\phi^p(\bar x)=\bar x^{p^{pn}}$, and therefore we know $0=\bar x^{p^{pn}}-\bar x$, and therefore that the polynomial $x^{p^{pn}}-x$ is divisible by $q_n(x)$.

Using the result above, we therefore see that $p^n=\deg q_n(x)\mid pn$. But $p^n\mid pn$ can only happen if $n=1$ or $n=2$ and $p=2$.

I think you can show that $q_1(x)\mid x^{p^p}-x$ pretty straight-forwardly, therefore showing that it must factor as elements of degree $p$ and degree $1$. But clearly it has no factors of degree $1$ since it has no roots in $\mathbb F_p$, so, since $\deg q_n=p$, $q_1(x)$ must be prime.

Then you have the last case, $x^4-x+1$ over $\mathbb F_2$, which you can brute force.