TITLE: Does $2^n \bmod n$ ever repeat?
QUESTION [8 upvotes]: Title basically says it all, but...
Is it known whether the sequence generated by $2^n \bmod n$ is periodic as $n$ traverses the natural numbers?
Just for some flavor, the first 50 elements:
{0, 0, 2, 0, 2, 4, 2, 0, 8, 4,
 2, 4, 2, 4, 8, 0, 2, 10, 2, 16,
 8, 4, 2, 16, 7, 4, 26, 16, 2, 4,
 2, 0, 8, 4, 18, 28, 2, 4, 8, 16,
 2, 22, 2, 16, 17, 4, 2, 16, 30, 24,
   ...}

REPLY [7 votes]: It's easy to prove that $2^{3^n} \equiv  3^n-1 mod(3^n)$. So if you consider the sequence $x_{n}=(2^{3^n} \equiv 3^n-1 
  mod(3^n))$ it's divergent to infinity, and assumes infinite distinct values. So the sequence can't be periodic.