I want to calculate the following limit
$lim_{n \to \infty}\ A={\begin{bmatrix}1 & 0 &0 & 0&0\\1-p & 0 & p & 0&0\\0 & 1-p & 0 & p&0\\0&0&1-p&0&p\\0&0&0&0&1\end{bmatrix}}^n$ where we know $0<p<1$.
I put some numbers instead of $p$ and calculated the above matrix for large $n$ and I observed that the limit matrix will be in shape of following matrix for $a,b,c,d,e,f \neq 0$
$$\begin{bmatrix}1 & 0 &0 & 0&0\\a & 0 & 0 & 0&b\\c & 0 & 0 & 0&d\\e&0&0&0&f\\0&0&0&0&1\end{bmatrix}$$
but the point is that I need to know exactly what $a,b,c,d,e,f$ are (regards to $p$).
Moreover, I think adding it would be helpful that the matrix $A$ is actually a transition matrix of a markov chain so as you can see the summation of each row is $1$.
another valid question is what would happen to limit if $A$ was an $N\times N$ matrix instead of a $5 \times 5$ one?
We see from the transition matrix $A$ that the Markov chain has two absorbing states—the first and last—while the rest are transient, i.e., the system eventually enters either the first or last state and stays there. As $n$ gets large, $A^n$ will approach a matrix $P$ of the shape that you’ve described. Each entry $p_{ij}$ of the non-zero columns is the probabilities of eventually reaching state $j$ if the system starts in state $i$.
To compute these probabilities, proceed as per @Ian’s comment. Each of the two non-zero columns will be a (right) eigenvector of $A$ corresponding to the eigenvalue $1$, that is, each will satisfy $(A-I)\mathbf v=0$. In this case, you only need to solve one such system of linear equations since we also have $p_{i5}=1-p_{i1}$.
As for the general $n\times n$ case, the result is similar: a matrix with only the first and last column non-zero, and the entries in those columns the probabilities of eventually reaching the corresponding absorbing state. To compute those probabilities, find a recurrence for the entries in one of the non-zero columns (the last one is the easier of the two to work with).