Order of $SL_2(\mathbb{Z}/ n\mathbb{Z})$ I've just left an exam of algebraic structures, and one of the questions asked to compute the order of $SL_2(\mathbb{Z}/ 5\mathbb{Z})$ (the 2x2 matrices with determinant $1$ over the field $\mathbb{Z}/ 5\mathbb{Z}$). The answer should be $120$, and a friend of mine could achieve that, but by methods of raw counting. My question is: Is there a way to compute the order of $SL_2(\mathbb{Z}/ n\mathbb{Z})$ for all $n$?
OBS: Although $120=5!$, I believe this is purely a coincidence.
 A: The size of $GL_2(\mathbb Z/n\mathbb Z)$ depends on the prime factorization of $n$. Say $n$ has prime factorization $n=\prod_i p_i^{\alpha_i}$ (chosen nontrivially, so that the $p_i$ are distinct and the exponents $\alpha_i$ are nonzero). Then the order of $GL_2(\mathbb Z/n\mathbb Z)$ is
$$
\prod_i p^{4(\alpha_i-1)}(p^2-1)(p^2-p).
$$
For more details, see this paper. (I should point out that all the formulas in the post easily generalize to $GL_d(\mathbb Z/n\mathbb Z)$; the fact that $d=2$ in my discussion isn't crucial, but I wanted to keep my answer simple.)
To find the order of $SL_2(\mathbb Z/n\mathbb Z)$ given the formula above, all we need to do is observe that $SL_2(\mathbb Z/n\mathbb Z)$ is the kernel of the determinant homomorphism $\det : GL_2(\mathbb Z/n\mathbb Z)\to (\mathbb Z/n\mathbb Z)^\times$. Since the group $(\mathbb Z/n\mathbb Z)^\times$ has order $\varphi(n)$ (here $\varphi$ is Euler's phi function), the order of $SL_2(\mathbb Z/n\mathbb Z)$ is
$$
\frac{1}{\varphi(n)}\prod_i p^{4(\alpha_i-1)}(p^2-1)(p^2-p)
= \frac{1}{n}\prod_i p^{4\alpha_i-2}(p^2-1)
= \prod_i p^{3\alpha_i-2}(p^2-1)
$$
A: First of all, do you know how many elements there are in $\textrm{GL}_n(\mathbb{F}_q)$? (As a generalisation of $\mathbb{Z}/n\mathbb{Z}$ where $n$ is prime.)
If one chooses $\textbf{r}_1$, the first row of a matrix, there are $q^n-1$ choices for this row (this accounts for all nonzero vectors in $(\mathbb{F}_q)^n$). Then, once $\textbf{r}_1$ is fixed, $\textbf{r}_2$ cannot be any of the $q$ multiples of $\textbf{r}_2$, so there are $q^n-q$ choices for $\textbf{r}_2$. Once both $\textbf{r}_1$ and $\textbf{r}_2$ are fixed, we can't have $\textbf{r}_3 = \alpha\textbf{r}_1 + \beta\textbf{r}_2$ for any $\alpha, \beta \in \mathbb{F}_q$, so we have $q^n-q^2$ choices for $\textrm{r}_3$. Proceeding this way, we find there are $q^n-q^{i-1}$ choices for $\textbf{r}_i$ and therefore $\left|\textrm{GL}_n(\mathbb{F}_q)\right| = (q^n-1)(q^n-q)\ldots(q^n-q^{n-1})$.
Now, if we define $\phi : \textrm{GL}_n(\mathbb{F}_q) \rightarrow \mathbb{F}_q^*$ by $\phi(M) = \textrm{det}(M)$ , we see $\phi$ is surjective and has kernel $\textrm{SL}_n(\mathbb{F}_q)$. Thus by the first isomorphism theorem, $\textrm{GL}_n(\mathbb{F}_q) / \textrm{SL}_n(\mathbb{F}_q) \cong \mathbb{F}_q^*$ and so $\left|\textrm{SL}_n(\mathbb{F}_q)\right| = \left|\textrm{GL}_n(\mathbb{F}_q)\right| / \left|\mathbb{F}_q^*\right| = \frac{(q^n-1)(q^n-q)\ldots(q^n-q^{n-1})}{q-1}$
A: Let $\mathbb F$ be a field.  Constructing an element of $\operatorname{GL}_n(\mathbb F)$ is the same as giving a basis of $\mathbb F^n$.  To do this, our first vector $v_1$ can be any non-zero vector.  Next, $v_2$ can be any vector not in $\operatorname{span}(v_1)$.  Continuing in this manner, $v_{i+1}$ can be any vector not in $\operatorname{span}(v_1, \ldots, v_i)$.  
Given any matrix in $\operatorname{GL}_n(\mathbb F)$, we can get an element in $\operatorname{SL}_n(\mathbb F)$ by dividing the last column by the determinant.  Similarly, by multiplying the last column, we see there is a bijection between the matrices with determinant $1$ and the matrices with determinant $a$ for any $a\in \mathbb F^{\times}$.
Now, let us see how large this group is when $\mathbb F$ is a finite field of size $q$.  We have $q^n-1$ choices for $v_1$, $q^n-q$ choices for $v_2$, and inductively $q^n-q^i$ for $v_{i+1}$.  Therefore, 
$$\left| \operatorname{GL}_n(\mathbb F_q)\right|=\prod_{i=0}^{n-1}(q^n-q^{i}), \qquad \left| \operatorname{SL}_n(\mathbb F_q)\right|=\frac{1}{q-1}\prod_{i=0}^{n-1}(q^n-q^{i}).$$
Setting $q=5, n=2$, we have $\left|\operatorname{SL}_2(\mathbb Z /5\mathbb Z)\right| =\frac{1}{4}(25-1)(25-5)=120$
