Consider a random walk on $\mathbb{Z}$ starting from $i >0$. With probability $p$ it moves to the nearest neighbor on the left, with the same probability it moves to the nearest neighbor on the right, with probability $q$ the walker dies. Naturally $2p+q=1$.
I want to estimate the probability that the walke reaches $0$ before reaching $N>i$ or before dying. I call this probability $P(i, N)$ and I try to calculate it. This probability solves the following equation, $$ P(i, N) = \, \, p \,P(i-1, N) + p\, P(i+1, N), $$ with boundary conditions $P(0, N) = 0$ and $P(L, N) = 1$. Is it right? What is the expression for $P(i,N)$?