If $A=\begin {bmatrix} a & b \\ 0 & 1 \end{bmatrix}$, find $A^n$ for positive integer $n$ 
If $A=\begin {bmatrix} a & b \\ 0 & 1 \end{bmatrix}$, find $A^n$ for positive integer $n$.

Now my method of solving these were to take $n=1,2,3..$, find the respective value and analyse the options to find the right one. It works well, but I never quite figured out how to do this properly, in case options aren’t given. Thanks!
 A: Hint
The characteristic equation is $$(\lambda-1)(\lambda-a)=0\to \lambda^2=
(a+1)\lambda+a$$Based on Cayley-Hamilton's theorem
$$A^2=(a+1)A+a$$
A: If $a=1$ then it is straightforward to show that $A^n = \begin{bmatrix}1 & nb \\ 0 & 1 \end{bmatrix}$.
Suppose $a \neq 1$. Then with $v_1 = e_1, v_2 = (-b, a-1)^T$ we have
$A^n v_1 = a v_1, A^n v_2 = v_2$. Let $V= \begin{bmatrix} v_1 & v_2, \end{bmatrix}$, then
$A = V \begin{bmatrix}a^n & 0 \\ 0 & 1 \end{bmatrix} V^{-1} = {1 \over ad}\begin{bmatrix}1 & -b \\ 0 & a-1 \end{bmatrix} \begin{bmatrix}a^n & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} d & -b \\ 0 & a \end{bmatrix} = \begin{bmatrix}a^n & {a^n-1 \over a-1} b \\ 0 & 1 \end{bmatrix}$.
This formula holds for all $n$, of course.
A: Another way if you're interesting. 
$A=B+C$ where $B=\begin {bmatrix} a & 0 \\ 0 & 1 \end{bmatrix}$ and $C=\begin {bmatrix} 0 & b \\ 0 & 0 \end{bmatrix}$
We have $B^n=\begin {bmatrix} a^n & 0 \\ 0 & 1 \end{bmatrix}$, $C^2=0$ and $BC=aCB=\begin {bmatrix} 0 & ab \\ 0 & 0 \end{bmatrix}$
So $A^n=(B+C)^n=B^n+\displaystyle\sum_{i=0}^{n-1}B^i C B^{n-1-i}$
We have $B^i C B^{n-1-i}=aB^{i-1}C B^{n-i}=\cdots=a^iCB^{n-1}=a^i \begin {bmatrix} 0 & b \\ 0 & 0 \end{bmatrix} $ so
$$A^n=B^n+\displaystyle\sum_{i=0}^{n-1}a^i C B^{n-1}=\begin {bmatrix} a^n & 0 \\ 0 & 1 \end{bmatrix}+\displaystyle\sum_{i=0}^{n-1}a^i \begin {bmatrix} 0 & b \\ 0 & 0 \end{bmatrix}=\begin {bmatrix} a^n & b\displaystyle\sum_{i=0}^{n-1}a^i \\ 0 & 1 \end{bmatrix}$$
If $a=1$ then $A^n=\begin {bmatrix} 1 & nb \\ 0 & 1 \end{bmatrix}$
If $a\neq 1$ then $A^n=\begin {bmatrix} a^n & b\frac{a^n-1}{a-1} \\ 0 & 1 \end{bmatrix}$
