Finding $x$'s parity in the discrete log problem Suppose $p$ is prime, and $g, a\in\mathbb F_p$ are given elements with $g$ a primitive root. The discrete log problem poses the task of finding an integer $x$ such that $g^x=a$. Show that even if $x$ cannot be recovered, one can check if $x$ is odd or even by inspecting the element $a^{(p-1)/2}$.

I'm not sure how to approach this question. I tried $g^{x(p-1)/2} = a^{(p-1)/2} = 1$.

Any help would be appreciated! Thanks.
Claim. $a^{(p-1)/2} = 1$ if and only if $x$ is even.

Proof. If $x$ is even, let $x = 2y$. Then
$$a^{(p-1)/2} = (g^x)^{(p-1)/2} = g^{2y(p-1)/2} = (g^{p-1})^y = 1^y = 1.$$

If $x$ is odd, let $x = 2y+1$. Then
$$a^{(p-1)/2} = g^{(2y+1)(p-1)/2} = \dots$$
(remember here that $g$ is a generator of $\mathbf{F}_p^*$).