A classic random walk problem that can be solved using the theory of Markov processes. At each play a gambler is supposed to have probability p of winning one unit and probability q (= 1−p) of losing one unit. The gambler starts with j units. Betting continues until either the gambler's fortune reaches N (in which case the gambler retires) or the gambler is ruined. If p = ½ then the probability of ruin is 1−(j/N), and otherwise it is