<s>[INST] Find all $n$ for which $504$ doesn't divide $n^8-n^2$ I have seen a similar problem where someone showed that it does divide $n^9-n^3$ but here one has to show that it isn't the case for $n^8-n^2$ for all $n$.
 [/INST] By the Chinese remainder theorem, $n^8-n^2$ is divisible by $504$ if and only if it is divisible by $8$, $7$ and $9$.


*

*Mod $8$, $n^2\equiv 0$ or $1$, except if $n\equiv \pm2\mod8$, hence $n^8-n^2=n^2(n^6-1)\equiv 0$, except if $n\equiv \pm2\mod8$, in which case $n^8-n^2\equiv 4$.

*Mod $7$, Lil' Fermat says $n^7\equiv n\mod 7$, hence $n^8-n^2\equiv n^2-n^2=0\mod7$.

*Mod $9$, $n^2\equiv 0$ if $n\equiv 0,\pm3$, and $n^6\equiv 1$ if $n\equiv \pm1,\pm 2, 4$, so $n^8-n^2\equiv 0\mod9$  for all $n$.


As a conclusion, $n^8-n^2\equiv 0\mod 504$, except if $n\equiv\pm2$ (i.e. $n\equiv 2,6$) $\bmod8$. As observed by @lhf, the simplifies to $n\equiv 2\mod4$.
</s>