Compute the $n$-th power of triangular $3\times3$ matrix I have the following matrix
$$
\begin{bmatrix}
1 & 2 & 3\\
0 & 1 & 2\\
0 & 0 & 1
\end{bmatrix}
$$
and I am asked to compute its $n$-th power (to express each element as a function of $n$). I don't know at all what to do. I tried to compute some values manually to see some pattern and deduce a general expression but that didn't gave anything (especially for the top right). Thank you.

Here is another variation based upon walks in graphs.

We interpret  the matrix $A=(a_{i,j})_{1\leq i,j\leq 3}$ with
  \begin{align*}
A=
\begin{pmatrix}
1 & 2 & 3\\
\color{grey}{0} & 1 & 2\\
\color{grey}{0} & \color{grey}{0} & 1
\end{pmatrix}
\end{align*}
  as adjacency matrix of a graph with three nodes $P_1,P_2$ and $P_3$ and for each entry $a_{i,j}\neq 0$ with a directed edge from $P_i$ to $P_j$ weighted with $a_{i,j}$.
 

Note: When calculating the $n$-th power $A^n=\left(a_{i,j}^{(n)}\right)_{1\leq i,j\leq 3}$ we can interpret the element $a_{i,j}^{(n)}$ of $A^n$ as the number of (weighted) paths of length $n$ from $P_i$ to $P_j$. The entries of $A=(a_{i,j})_{1\leq i,j\leq 3}$ are the weighted paths of length $1$ from $P_i$ to $P_j$.
See e.g. chapter 1 of Topics in Algebraic Combinatorics by Richard P. Stanley.

Let's look at the corresponding graph and check for walks of length $n$.
  
  
*
  
*We see there are no directed edges from $P_2$ to $P_1$ and no directed edges from $P_3$ to $P_2$ and from $P_3$ to $P_1$ which implies there are no walks of length $n$ either. So, $A^n$ has due to the specific triangle structure of $A$ necessarily zeroes at the same locations as $A$.
  \begin{align*}
A^n=
\begin{pmatrix}
. & . & .\\
\color{grey}{0} & . & .\\
\color{grey}{0} & \color{grey}{0} & .
\end{pmatrix}
\end{align*}
  
*It is also easy to consider the walks of length $n$ from $P_i$ to $P_i$. There is only one possibility to loop along the vertex weighted with $1$ from $P_i$ to $P_i$ and so the entries $a_{i,i}^{(n)}$ are
  \begin{align*}
1\cdot 1\cdot 1\cdots 1 = 1^n=1
\end{align*}
  and we obtain
  \begin{align*}
A^n=
\begin{pmatrix}
1& . & .\\
\color{grey}{0} & 1 & .\\
\color{grey}{0} & \color{grey}{0} & 1
\end{pmatrix}
\end{align*}

and now the more interesting part

  
*
  
*$P_1$ to $P_2$:
The walks of length $n$ from $P_1$ to $P_2$ can start with zero or more loops at $P_1$ followed by a step (weigthed with $2$) from $P_1$ to $P_2$ and finally zero or more loops at $P_2$. All the loops are weighted with $1$. There are $n$ possibilities to walk this way
  \begin{align*}
a_{1,2}^{(n)}=2\cdot 1^{n-1}+1\cdot 2\cdot 1^{n-2}+\cdots +1^{n-2}\cdot 2\cdot 1+1^{n-1}\cdot 2=2n
\end{align*}
  
*$P_2$ to $P_3$:
Symmetry is trump. When looking at the graph we observe the same situation as before from  $P_1$ to $P_2$ and conclude
\begin{align*}
a_{2,3}^{(n)}=2n
\end{align*}
  
  
*
  
*$P_1$ to $P_3$:
Here are two different types of walks of length $n$ possible. The first walk uses the weight $3$ edge from $P_1$ to $P_3$ as we did when walking from $P_1$ to $P_2$ along the weight $2$ edge. This part gives therefore
  \begin{align*}
3\cdot 1^{n-1}+1\cdot 3\cdot 1^{n-2}+\cdots +1^{n-2}\cdot 3\cdot 1+1^{n-1}\cdot 3=3n\tag{1}
\end{align*}
  The other type of walk of length $n$ uses the hop via $P_2$. We observe it is some kind of concatenation of walks as considered before from $P_1$ to $P_2$ and from $P_2$ to $P_3$. In fact there are $\binom{n}{2}$ possibilities to place two $2$'s in a walk of length $n$. All other steps are loops at $P_1,P_2$ and $P_3$ and we obtain
  \begin{align*}
\binom{n}{2}\cdot 2\cdot 2=2n(n-1)\tag{2}
\end{align*}
  Summing up (1) and (2) gives
  \begin{align*}
a_{1,3}^{(n)}=3n+2n(n-1)=n(2n+1)
\end{align*}

and we finally obtain
\begin{align*}
A^n=\left(a_{i,j}^{(n)}\right)_{1\leq i,j\leq 3}=\begin{pmatrix}
1& 2n & n(2n+1)\\
\color{grey}{0} & 1 & 2n\\
\color{grey}{0} & \color{grey}{0} & 1
\end{pmatrix}
\end{align*}
