Let $G$ be a group of all $2 \times 2$ matrices over $Z_p$ with determinant $1$ under matrix multiplication. To find the order of $G$. I am solving some previous year's question paper of our college and found the following problem:
Let $p$ be a prime number. Let $G$ be a group of all $2 \times 2$ matrices over $Z_p$ with determinant $1$ under matrix multiplication. To find the order of $G$.
I am struck with the problem. Please Help!
 A: Hint: look at two cases, according to whether the top left element is $0$ or not.
A: First select the elements of the main diagonal.
There $p-1$ ways to select them so that their product is $1$.
If the product is $1$ the product of the elements of the other diagonal must be $0$. There are $2p-1$ ways to select them so at least one of them is a multiple of $p$.
This gives us $(p-1)(2p-1)$ matrices.
There are $p^2-p+1$ selections in which the product of the diagonal is not $1$.
No matter what the product of the diagonal is, the product for the other diagonal shall be fixed, and will be non-zero. There are $p-1$ ways to choose them so that they give the selected product.
So we have $(p-1)(2p-1)+(p^2-p+1)(p-1)=(p-1)(p^2+p)=p^3-p$ such matrices.
A: A general matrix here is $\begin{bmatrix}
 a&b \\ 
 c&d 
\end{bmatrix}$ with $ad-bc=1$. If $a=0$ then $d$ can be anything and for any non-zero $b$, $c$ is $\frac{-1}{b}$. Hence there are $p$ choices for $d$, $p-1$ choices for $b$ and one choice for each $a$ and $c$, giving us $p(p-1)$ matrices. If $a\neq0$ then $d=\frac{1+bc}{a}$ and $b$ and $c$ can be anything giving us $(p-1)p^2$ such matrices for a total of $p(p-1)+(p-1)p^2=p^3-p$ matrices. 
