I'm reading the probability chapter from an interview book called A Practical Guide to Quantitative Finance Interview, and cannot make sense or understand one of the problems called "Gambler Ruin Problem" (4.3 Conditional Probability and Bayes' Formula":
A gambler start with an initial fortune of i dollars. On each successive game, the gambler wins 1 dollar with probability p, or loses 1 dollar with probability q = 1-p. He will stop if he either accumulates N dollars or loses all his money. What is the probability that he will end up with N dollars?
Here is the solution:
From any initial state i(the dollars the gambler has), let $P(i)$ be the probability that the gambler's fortune will reach N instead of 0. The next state is either $i+1$ with probability p or i-1 with probability q. So we have:
$P(i) = pP(i+1) + qP(i-1)$
Could any expert explain why the above equation holds?