as far as I can see, Lagrange says:
IF
$p$ = prime, $p-1 = 2*q$, $q$ = prime
THEN
$g^q \mod p = 1 \implies \text{order}(g) = q$
$g^q \mod p \neq 1 \implies \text{order}(g) = p-1$
However if i try to calculate the order of $6 \mod 7$:
$p = 7 \implies p-1 = 6 = 2 \cdot 3 \implies q=3$, $6^3 \mod 7 = 6 \neq 1 \implies \text{order}(6)$ should be $6$.
But doing it by hand i get the following:
$6^1 \mod 7 = 6$
$6^2 \mod 7 = 1$
$6^3 \mod 7 = 6$
$6^4 \mod 7 = 1$
...
so order should be $2$ instead of $6$ right? What am I missing, i really don't get it :(
The only divisors of $2q$ are $1$, $2$, $q$, and $2q$. Thus they are the only candidates for the order of $g$.
If $g^q\equiv 1\pmod{p}$, then $g$ has order $1$ or $q$.
If $g^q\not\equiv 1\pmod{p}$, then $g$ has order $2$ or $2q$.