Skip to main content
2 of 2
added 9 characters in body
kodlu
  • 10.4k
  • 2
  • 36
  • 55

If $gcd(e,\lambda(N))=1,$ the sequence is purely periodic. Otherwise it may have an initial segment followed by a cycle, as you observe. Its maximal period divides the Carmichael function $\lambda(N)$ which is $\textrm{lcm}(p-1,q-1)$ when $N=pq,$ with $p,q$ prime.

Note that $2$ divides $\lambda(N)$ in this case, and explains the tendency in the period which you noticed. The paper Period of the power generator and small values of the Carmichael function by Friedlander, Pomerance and Shparlinski available here has a detailed discussion.

kodlu
  • 10.4k
  • 2
  • 36
  • 55