For a random walk of probability $p$ for +1 and $q=1-p$ for -1, what is the probability of reaching point $x > 0$ for the first time after $n$ steps?
Here is my thought process:
For $x < n$, this is clearly impossible, so probability is 0. For $x = n$, the probability is $p^x$.
For $x > n$, it's more tricky. In this case, $n$ must be greater than $x$ by an even number, otherwise it is impossible to reach $x$ for the first time after $n$ steps. Thus a condition is $(x - n) \,\, \mathrm{mod} \,\, 2 = 0$.
Now, the last step which the random walk takes must be the step to make the walker reach point $x$. Thus the probability is $p *\mathrm{P}(x - 1, n-1)$ where $\mathrm{P}(x - 1, n-1)$ is the probability that the random walker finishes at point $x-1$ after $n-1$ steps AND never goes past point $x-1$ during these $n-1$ steps.
I know how to calculate the probability that the walker finishes at point $x-1$ after $n-1$ steps because that's simple random walk, but I don't know how to include the AND condition. I suppose we would have to subtract all possible paths where the random walker goes past point $x-1$ in $n-1$ steps, but I don't know how to find all such possible paths for the general case either.