What is the order of $2$ in $(\mathbb{Z}/n\mathbb{Z})^\times$?

Is it there some theorem that makes a statement about the order of $2$ in the multiplicative group of integers modulo $n$ for general $n>2$?


Let me quote from this presentation of Carl Pomerance:

[...] the multiplicative order of $2 \pmod n$ appears to be very erratic and difficult to get hold of.

The presentation describes, however, some properties of this order. The basic facts have already been elucidated by @HagenvonEitzen in his comment.


As others have pointed out, this is not trivial in the slightest. There are a few things you can find out, as Hagen von Eitzen pointed out in the comments. I created the following plots for $n\in 1\ldots 1000,~~~~~ 1\ldots 10000, ~~~~~1\ldots 100000$.

enter image description here

enter image description here

enter image description here

There are certain things from this picture that are easy to make sense of, notably the highest line, which is $y = x-1$ and then the other prominent lines for small divisors of $n-1$. I am intrigued by the few points that lie between $n-1$ and $\frac{n-1}{2}$.

The first few elements of this appear to be: $$9,25,27,81,121,125,169,243,361,625,729,841...$$

Which are all powers of prime numbers, which makes sense. This is actually A108989, and these are those non-prime numbers $n$ for which the multiplicative order of $2$ modulo $n$ is $\phi(n)$.

I've also tallied the most common orders for the first $1,000,000$ odd integers and the first few were: $$\{2, 155171\}, \{4, 108716\}, \{8, 73643\}, \{12, 67834\}, \{6, 57771\}, \{1, 55868\}, \{16, 46866\}, \{24, 45317\}, \{48, 31026\}, \{32, 23299\}, \{36, 20669\}, \{96, 16278\}, \{72, 15858\}, \{20, 14476\}, \{10, 13413\}$$

See what you can make of that, it isn't in the OEIS.