TITLE: Nicer proof that $2^{n+2}$ divides $3^m-1$ if and only if $2^{n}$ divides $m$
QUESTION [10 upvotes]: (I've accepted Carl's answer because he was first, but robjohn and sirous each gave very nice answers as well.)

I'm interested in the highest power of two that divides $3^m-1$ for even $m \geq 2$. In fact, I can show that this is exactly four times the largest power of two dividing $m$. I.e., $2^{n+2}$ divides $3^m-1$ if and only if $2^{n}$ divides $m$ for $n \geq 1$.
But, my proof seems too tedious for such a nice fact. I've written it up below, but since I want a better proof, you might want to just ignore it. (My motivation comes from finite fields, but the question seems interesting regardless.)

Suppose that $2^{n+2}$ divides $3^m-1$. The proof proceeds in two steps. First, we show that the result holds when $m$ is itself a power of two. I.e., $2^{n+2}$ divides $3^{2^{n'}}-1$ if and only if $n \leq n'$. Next, we show that for any $m$ such that $3^m-1$ is divisible by $2^{n+2}$, we must have $\gcd(m,2^{n}) = 2^{n}$.
For the first part, we observe the factorization
$$
3^{2^{n'}} - 1 = (3^{2^{n'-1}} +1) (3^{2^{n'-2}} + 1) \cdots (3^2+1)(3+1)(3-1)
\;. 
$$
(This is just the factorization of the $2^{n'}$th cyclotomic polynomial and does not use any properties of the number 3.) Since $3^a + 1 = 2 \bmod 4$ for all even $a$, the largest power of two dividing this is exactly $2^{n'+2}$, as needed. (There are $n'+1$ terms, each even. The only term divisible by $4$ is the term $3+1=4$.)
For the second part, we notice that if $2^{n+2}$ divides $3^m-1$, since $2^{n+2}$ also divides $3^{2^{n}} - 1$, $2^{n+2}$ must divide their difference $3^{\min(2^{n},m)}(3^{|m-2^{n}|}-1)$. Since $3^{\min(2^{n},m)}$ is odd, this in turn implies that $3^{|m-2^n|}-1$ is divisible by $2^{n+2}$. We can repeat this procedure many times to simulate the Euclidean algorithm in the exponent, eventually showing that $3^{\gcd(m,2^{n})} - 1 $ is divisible by $2^{n+2}$. Of course, $\gcd(m,2^{n})$ must be a power of two, and therefore the previous argument implies that it $\gcd(m,2^{n}) = 2^{n}$, as needed.

REPLY [2 votes]: For $k\ge0$ and odd $p$,
$$
3^{p2^k}-1=\left(3^{2^k}-1\right)\overbrace{\left(3^{(p-1)2^k}+3^{(p-2)2^k}+\cdots+1\right)}^\text{$p$ terms}
$$
For $k\ge2$,
$$
3^{2^k}-1=\left(3^{2^{k-1}}-1\right)\overbrace{\left(3^{2^{k-1}}+1\right)}^{2\pmod4}
$$