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$.
 A: 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$.
A: As I said, $n^8-n^2=n^2(n^6-1)$ and $504=2^3\times 3^2\times 7$.
If $n$ is not a multiple of $7$, then $n^6-1$ is divisible by $7$ by Fermat and on the other hand if $n$ is a multiple of $7$, $n^2$ is divisible by $7$.
As for the powers of $2$, if $n$ is even, $n^2$ is divisible by $8$ if $n \equiv 0(\textrm{mod}\hspace{3pt} 4)$.
If $n$ is odd, then $n^6-1$ is divisible by $8$. (We have $n^2\equiv 1(\textrm{mod}\hspace{3pt} 8)$ for $n$ odd.)
As for the powers of $3$, if $n$ is a multiple of 3 we are done as $n^2$ is divisible by $9$. Otherwise, Fermat-Euler tells us $n^6\equiv 1(\textrm{mod}\hspace{3pt} 9)$
So our only case that fails is if $n$ is even, and $n 2(\textrm{mod}\hspace{3pt} 4)$.(In other words, $4k+2$ where $k$ is an integer is the answer.)
