Let's say we take one dimensional random walk. The origin is at point $0$ and next, there are $n+1$ integres, so we have: $0, 1, 2, 3, 4, ... n+1$. W start in the point $1$ from which we make a $1$ step forward with probability p and $1$ step back with probability $q = 1 - p$. What is the probability that we will reach the point $n+1$ before returning to $0$?
I found that question: Probability to reach $a>0$ before returning to the origin in a one dimensional random walk.
It is fairly similar. However, looking at the first response I think there is an error - the recurrence should look like that:
$f(x) = f(x-1) \cdot p + f(x+1) \cdot q$
With $f(0) = 0$, $f(n+1) = 1$.
Now, having said that, what would be the solution? Is it any similar as in the linked question (since I think there is an error)? Any help would be much appreciated.
Their formula is correct. The probability of reaching $a$ starting at $k$ is the same as the expected probability of reaching $a$ from where it will be after $k$. With probability $p$, that will be $k+1$, and with probability $q$ that will be $k-1$. $$P(reach A|k)=pP(reach A | k+1)+qP(reach A | k=1)$$