When is $a^k \pmod{m}$ a periodic sequence? Let $a$ and $m$ be a positive integers with $a < m$.  Suppose that $p$ and $q$ are prime divisors of $m$.  Suppose that $a$ is divisible by $p$ but not $q$.  
Is there necessarily an integer $k>1$ such that $a^k \equiv a \pmod{m}$?  
Or is it that the best we can do is say there are $n>0$ and $k>1$ such that $a^{n+k} \equiv a^n \pmod{m}$
What can be said about $n$ and $k$?
EDIT: Corrected to have $k>1$ rather than $k>0$.
EDIT: The following paper answers my questions about $n$ and $k$ very nicely.
A. E. Livingston and M. L. Livingston, The congruence $a^{r+s} \equiv a^r \pmod{m}$, Amer. Math. Monthly $\textbf{85}$ (1978), no.2, 97-100.
It is one of the references in the paper Math Gems cited. Arturo seems to say essentially the same thing in his answer.

A nice presentation of such semigroup generalizations of the Euler-Fermat theorem and related number theory is the following freely available paper
S. Schwarz, The role of semigroups in the elementary theory of numbers, Math. Slovaca, Vol. 31 (1981) pp. 369–395.
