TITLE: How do I prove that $a\in (\mathbb{Z}_{p}^{*})^2 \Leftrightarrow a^{\frac{p-1}{2}}\equiv 1 \pmod p$
QUESTION [4 upvotes]: $p$ is prime number $>2$ and $a$ is a square.   $\mathbb{Z}_{p}^{*} $ is a cyclic group.
I need to show that $$ a\in (\mathbb{Z}_{p}^{*})^2 \iff a^{\frac{p-1}{2}}\equiv 1 \pmod p $$
Any ideas how? 
I need to prove two directions...
Thank you!
Q: Have you any idea how do I prove this direction? $\Longleftarrow$
(I understand the other direction, but please help me with this one...)

REPLY [2 votes]: By little Fermat, we know that for any $a\neq 0$ in $\Bbb Z_p^\times$ we have $a^{p-1}=1$. This means that $a^{\frac{p-1}2}=\pm 1$. It is a theorem that in $\Bbb Z_p^{\times}$, exactly half of the elements are squares (namely, those that correspond to $1^2,2^2,\ldots,\left(\frac{p-1}2\right)^2$) and half are non-squares. But by Lagrange's theorem, $a^{\frac{p-1}2}=1$ has at most $\dfrac{p-1}2$ solutions and by the previous claim at least $\dfrac{p-1}2$ solutions. Thus, it has exactly $\dfrac{p-1}2$ solutions, the squares $\mod p$. Thus if $a=b^2$ the equations holds, and if $a$ is not a square the equation doesn't.
ADD Using $\Bbb Z_p^\times$ is cyclic. Let $g$ be a primitive root modulo $p$. We can write $a=g^k$ for some $k$. By $g^{k(p-1)/2}=1$, it follows that ${\rm ord}(g)=p-1\mid (p-1)k/2$. This gives $k/2$ is an integer, so $k=2m$, and $a=g^{2m}=g'^2$ where $g'=g^m$.
{"set_name": "stack_exchange", "score": 4, "question_id": 580804}