I take it you want to be prime. The case is trivial, so we'll assume to be odd. Then if and if

If then by Euler's criterion In this case is not a quadratic residue modulo (and so it certainly can't be a quartic residue modulo we also have

Consider

(i) Suppose As in this case, by Fermat's little theorem.

(ii) Conversely suppose Then is even, i.e. Let be a primitive root and set Then divides But cannot divide otherwise which would contradict the fact that, as a primitive root, has order in the multiplicative group of the integers modulo Hence divides and we are done.