How to find all values of $r $ such that $n^r\equiv n\pmod{10^a}$ implies $n^2\equiv n\pmod {10^a}$? If $r$ is odd and $n\equiv-1\pmod {10^a}$ then $n^r\equiv n\pmod{10^a}$ but $n^2\not\equiv n\pmod{10^a}$.
If $r$ is even, then for $r=2$ this is clearly true, but I found that for $r=6$, $16^6\equiv16\pmod{100}$ while $16^2\not\equiv16\pmod{100}$.
I wonder that what can we say when $r$ is even? Could anyone give me some hint, please?
 A: Assume for sake of simplicity that $n$ is not divisible by $2$ or $5$, meaning that $n$ is invertible modulo $10^a$.
Then you are asking for which $r$ we have, for all $n$, $n^{r-1}\equiv 1 [10^a]\Rightarrow n\equiv 1 |10^a]$. This exactly means that you want $(\mathbb{Z}/10^a\mathbb{Z})^\times$ to have no elements of order dividing $r-1$ other than $\bar{1}$.
The group $(\mathbb{Z}/10^a\mathbb{Z})^\times$ is cyclic of order $4$ if $a=1$, isomorphic to $ \mathbb{Z}/{2\mathbb{Z}}\times\mathbb{Z}/{4\mathbb{Z}}\times \mathbb{Z}/{5\mathbb{Z}}$ if $a=2$, and isomorphic to $\mathbb{Z}/{2\mathbb{Z}}\times \mathbb{Z}/{2^{a-2}\mathbb{Z}} \times\mathbb{Z}/{4\mathbb{Z}}\times \mathbb{Z}/{5^{a-1}\mathbb{Z}}$ if $a\geq 3$.
The possible values for the order $d$ of an element of the former group are:
$d=1,2,4$ if $a=1$.
$d=1,2,4,5,10,20$ if $a=2$
$d=2^k 5^\ell$ , $0\leq k \leq 2, 0\leq \ell\leq a-1$ if $a=3$
$d=2^k 5^\ell$ , $0\leq k \leq 2^{a-2}, 0\leq \ell\leq a-1$ if $a\geq 4$
Hence the set of values $r $which answers your question are $r=2$ and integers $r$ such that $r-1$ do not divide any of the previous $d$
But for each case, any divisor of $d$ in the list is also in the list.
So the final answer is :
$r=2$ and $r\neq d+1, d>1$ where $d$ is in the list (for each case)
The case where $n$ is divisible by $2$ or $5$ deserve a more careful treatment, but I don't have time right now.
