if $a^{(p-1)/2}$≡ -1(mod p) then the order of a mod p is p-1 Prove or disprove
Suppose that p is an odd prime , if $a^{(p-1)/2}$≡ -1(mod p) then the order of a mod p is p-1
I think it is true statement , $a^{(p-1)/2}$≡ -1(mod p) by squaring both side we get $a^{(p-1)}$≡ 1(mod p) then the order of a mod p is p-1
is that right answer ?
 A: The claim is false: $a$ has order $p-1$ iff $\frac{p-1}{2}$ is the smallest exponent $k$ such that $a^k=-1$.
So, for a counterexample, we have to find $a$ with even order $n< p-1$. Then $a^{n/2}=-1$. Moreover, to get $a^{(p-1)/2}=-1$, we need $(p-1)/n$ to be odd.
Now, $a=p-1$ always has order $2$. Therefore, the easiest counterexample is $a=p-1$, when $p \equiv 3 \bmod 4$ because then $(p-1)/2$ is odd.
There are some more interesting counterexamples which have $n>2$:


*

*$p=13, a=5$. Then $ord(a)=4$.

*$p=19, a=8$. Then $ord(a)=6$.
Counterexamples with $n>2$ exists for these primes:
$$
13,19,29,31,37,41,43,53,61,67,71,73,79,89,97,101,103,109,113,127,131,137,139,\dots
$$
but this sequence is not in OEIS.
These are the primes $p$ such that $p-1=2u$ with $u$ odd composite or $p-1=4v$ with $v >1 $ odd. Then we can take in the first case $n=2w$, where $w$ is a nontrivial factor of $u$, and $n=4$ in the second case.
A: Let $ p =4k +3$. Then $ (p-1)/2 = 2k+1$. Now let $ a= p-1$. Then we see that $ a^2 $ is $1$ modulo $p$. So  order  of $a$ is 2.Also  $ a^{p-1/2} = (p-1)^{2k+1} \equiv -1 $ modulo $p$.(by the expansion ). Thus this is a general counterexample and it is not true.
A: Let $p=7$ and $a=6$. Then $a^{\frac{p-1}{2}}=6^\frac{7-1}{2}=6^3=216\equiv -1\pmod 7$. But $ord_7(6)=2$. Hope this helps and I think this was a counterexample not shown in the answer above. But correct me if I am wrong.
