<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] 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.)
</s>