The gambler''s ruin problem

Consider a gambler who starts with an initial fortune of $1 and then on each successive gamble either wins $1 or loses $1 independent of the past with probabilities p and q = 1−p respectively. Let R n denote the total fortune after the n th gamble. The gambler's objective is to reach a total fortune of $N , without first getting ruined (running out of money). If the gambler succeeds, then the gambler is said to win the game. In any case, the gambler stops playing after winning or getting ruined, whichever happens first. There is nothing special about starting with $1, more generally the gambler starts with $i where 0 < i < N. While the game proceeds, {R n : n ≥ 0} forms a simple random walk