p^2 dividing n^8-n^4+1 When trying to see if a number of the form $n^8-n^4+1$ can be divisible by the square of a prime, I found that it can indeed. The first few values for $n$ are
412, 786, 1417, 1818, 2430, 2640, 2809, 2822, 2899 ...
and the first few such primes $p$ (in increasing order) are
73, 97, 193, 241, 313, 337, 409, 433, ...
Interestingly enough, the latter is precisely the beginning of this sequence which lists the primes of the form $x^2+24y^2$. I am quite sure that this cannot be a pure coincidence and that some deep number theory must be involved. The number $24$ is not accidental either, as $n^8-n^4+1=\Phi_{24}(n)$, with $\Phi_k(x)$ being the $k$th cyclotomic polynomial. Maybe there is some relation to the field $\mathbb{Q}(\zeta_{24})$...
So, the question is if the following is true:
Conjecture. A prime $p$ has the form $x^2+24y^2$ if and only if $p^2$ divides $n^8-n^4+1$ for some $n$.
 A: There is another proof which is somewhat easier.
Since the multiplicative group of $\mathbb{Z}/p\mathbb{Z}$ is cyclic there exists
$x$ such that $\Phi_{24}(x) = 0 (mod p)$ iff $24 | p-1$. Notice that in this case
$\Phi_{24}(x)$ has $8$ different roots in $\mathbb{Z}/p\mathbb{Z}$ and the derivative
at each root is not divisible by $p$, which implies that any root if $\Phi_{24}$
in $\mathbb{Z}/p\mathbb{Z}$ can be lifted to a root in $\mathbb{Z}/p^k\mathbb{Z}$
(for all $k$) and even in $p$-adics $\mathbb{Z}_p$.
Here there is nothing special about $24$, and one can replace it with any integer.
A: Your conjecture is true in the light of the following statements.
Proposition 1. A prime $p$ has the form $x^2+24y^2$ if and only if $p\equiv 1\pmod{24}$.
Proposition 2. A prime square $p^2$ divides $\Phi_{24}(n)$ for some $n$ if and only if $p\equiv 1\pmod{24}$.
Proof of Proposition 1. The four equivalence classes of binary quadratic forms of discriminant $-96$ are represented by $x^2+24y^2$, $3x^2+8y^2$, $4x^2+4xy+7y^2$, $5x^2+2xy+5y^2$. Looking at the values in $(\mathbb{Z}/96\mathbb{Z})^\times$ assumed by these four quadratic forms, we see that they are in four different genera. This means that if $Q(x,y)$ is any of these forms and $p\geq 5$ is any prime, then $Q(x,y)$ represents $p$ if and only if it does so modulo $96$. In particular, $x^2+24y^2$ represents $p$ if and only if $p\equiv 1,25,49,73\pmod{96}$, i.e. when $p\equiv 1\pmod{24}$.
Proof of Proposition 2. By Hensel's Lemma, the square of a prime $p\geq 5$ divides $\Phi_{24}(n)$ for some $n$ if and only if $p$ divides $\Phi_{24}(m)$ for some $m$. The latter property holds if and only if $\mathbb{F}_p$ contains a primitive $24$-th root of unity, i.e. when $p\equiv 1\pmod{24}$.
References: Rose - A course in number theory; Cox - Primes of the form $x^2+ny^2$
