I'm posting this question because user last seen is more than $5$ years ago
I have some confusion on this answer
It is written that
Let $G$ be the set of non-zero elements of $\mathbb{Z}_p$. $G$ is a commutative group of order $p-1$. Let $f\colon G \rightarrow G^2$ be the map such that $f(m) = m^2$. $f$ is a surjective homomorphism. Hence $G^2$ is isomorphic to $G/\ker(f)$. Since $\ker(f) = \{1, -1\}$ and $p$ is odd, $|ker(f)| = 2$. Hence $|G^2| = (p-1)/2$.
My question : Why is $f$ a surjective homomorphism ?
My thinking :Let define the map $f : \mathbb{Z}^*_p \to \mathbb{Z}^*_p $ by $f(x)=x^2$
Here order of $ G=\mathbb{Z}^*_p= p-1$ where $p$ is odd prime
We can't use Bezout 's theorem here because $2$ and $p-1$ are not relatively prime
This implies $f$ is not surjective
For example take $G= \mathbb{Z}^*_3$
$\mathbb{Z}^*_p = \{1,2,3,...,p-1\} \implies \mathbb{Z}^*_3=\{1,2\}$
$f:\mathbb{Z_3}^* \to \mathbb{Z_3}^*$ defined by $f(x) =x^2$
$f(1)=1$ , $f(2)=2^2=4=1 \bmod 3$
Therefore $f$ is not onto