Subgroup of matrices exercise Let $G=\{\left( \begin{array}{ccc}1 & b  \\ 0 & a  \\ \end{array} \right) : a,b \in \mathbb Z_7, a \neq 0\}$. Find the order of $G$.  For each prime $p$ such that $p$ divides $|G|$, find all the elemens in $G$ that have order $p$.
I know that $G$ is a subset of the $2 \times 2$ matrices with coefficients in $\mathbb Z_7$. Is is pretty simple to construct an injective function from the set of such matrices and $\mathbb Z_7 \times \mathbb Z_7  \times \mathbb Z_7  \times \mathbb Z_7$, since the codomain is finite, then so is $G$. I have no idea how to find the cardinality of $G$ from here.
For the other part, if $A \in G$, then $|A|$ is the $n \in \mathbb N_0$ such that $nA=\left( \begin{array}{ccc}n & nb  \\ 0 & na  \\ \end{array} \right)= Id_2$. So, I need to find the minimum $n$ such that $$ n \equiv 1 (7),$$ $$nb \equiv 0 (7),$$ $$na \equiv 1 (7)$$
I am not so sure how to solve these equations. I would appreciate some help.
 A: Hint.  For elements of order $2$ you need
$$\pmatrix{1&b\cr0&a\cr}^2=\pmatrix{1&0\cr0&1\cr}\quad\hbox{but}\quad
  \pmatrix{1&b\cr0&a\cr}\ne\pmatrix{1&0\cr0&1\cr}\ .$$
That is,
$$\pmatrix{1&b+ab\cr0&a^2\cr}=\pmatrix{1&0\cr0&1\cr}\quad\hbox{but}\quad
  \pmatrix{1&b\cr0&a\cr}\ne\pmatrix{1&0\cr0&1\cr}\ .$$
Since $a^2=1$ we have $a=\pm1$: note that this is true modulo $7$, as it is in real arithmetic.  If $a=1$ the equality gives $2b=0$, but this contradicts the inequality.  So $a=-1$ and $b$ can be anything.  The matrices of order $2$ are
$$\pmatrix{1&b\cr0&-1\cr}\ ,\quad b\in{\Bbb Z}_7\ .$$
You can investigate other orders similarly.
For the order of $G$, I think Jyrki's first comment should be a sufficient hint.
A: Note that there is an obvious bijection $G\to \Bbb Z_7\setminus\{0\}\times\Bbb Z_7$ (can you find it?). It follows that 
$$
|G|=|\Bbb Z_7\setminus\{0\}|\times|\Bbb Z_7|=6\times 7=42=2\times 3\times 7
$$
Thus the only primes dividing $|G|$ are $2$, $3$, and $7$.
For the second part of your question note that 
$$
A = \begin{pmatrix}1 & b\\ 0 & a\end{pmatrix}
$$
satisfies
$$
A^k=
\begin{pmatrix}
1 & b\cdot\sum_{i=0}^{k-1}a^i \\ 0 & a^k
\end{pmatrix}
$$
Hopefully this is enough to get you started.
A: Number of choices for $b$ are $7$ and that for $a$ are $6$, therefore the total number such matrices is $42$. This shows $|G|=42$.
Use the following to get the the matrices of different orders.
$$
\begin{bmatrix}
1 & b\\
0 & a
\end{bmatrix}^n
=
\begin{bmatrix}
1 & b\left(\frac{a^n-1}{a-1}\right)\\
0 & a^n
\end{bmatrix}
$$
