Does $2^n \bmod n$ ever repeat?

304 Views Asked by At

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,
   ...}
3

There are 3 best solutions below

4
On BEST ANSWER

$a_n=0$ iff $n$ is a power of $2$. This is obviously not periodic.

0
On

If the sequence be periodic, there should exist $M$ s.t. $\forall n,2^n\,mod\,n<M$.

Choose $k$ s.t. $2^k>M$. Choose big prime $p>2^k$.

Let $n=pk$ then $2^n\equiv 2^k$ mod $p$. Thus, $2^n\,mod\,n\ge 2^k$. (contradiction)

0
On

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.