I am trying to work out a general formula for the solutions of this congruence so that I can find the number of solutions in the set specified. I tried using Chinese remainder theorem on the fact that the congruence is true for module 3 and 13;
$(x)^{39} \equiv x \pmod 3$
$x^{39} \equiv x \pmod {13}$
Then I used FLT and get to:
$x^2 \equiv x \pmod 3$
$x^3 \equiv x \pmod {13} $
However I tried several ways to work from here to get a general formula, but one of them seem to be correct. Any help is appreciated. Thanks in advance.
The chinese remainder theorem ensures that $$x^{39}\equiv x\mod 39$$ is true if and only if both $$x^{39}\equiv x\mod 13$$ and $$x^{39}\equiv x\mod 3$$ are true. It is easy to see that $x^{39}\equiv x\mod 3$ is true for every integer $x$ (Just insert $-1,0,1$) , so $x^{39}\equiv x\mod 13$, which is equivalent to $x^3\equiv x\mod 13$ because we can reduce the exponent modulo $12$, unless $13|x$ , but in this case, the equivalence is obvious. So, we have $$13|(x-1)x(x+1)$$, so, we have $$x\equiv -1,0\ \ or\ \ 1\mod 13$$
Now, it should be easy to determine the solutions.