A gambler enters casino with $k$ dollars and he starts betting $1$ dollar each time, with probability $1/2$ he wins $1$ dollar, and with probability $1/2$ he loses his bet (1 dollar), and to win he needs to reach $n$ dollars before getting ruined.
So if he reaches $n>k$ amount, then he wins and leaves, or he loses all his money and leaves.
Find a formula to calculate the probability of the gambler’s winning using $n$ and $k=1$, and $p= 1/2$.
Hint: let $p_n$ denote the probability that he wins starting with $n$ dollars.
then $P_n= pP_{n+1}+(1-p)P_{n-1}$, with $P_0=0, P_k=1$.
Let's suppose that the solution is of the form $P_n= \theta^n$(From techniques for solving ODE).
Substitute to get
$\theta^n=p\theta^{n+1}+(1-p)\theta^{n-1} \Rightarrow \theta=p\theta^2+(1-p)$
and solving it we get $\theta =1, \frac{1-p}{p}$ So we get $a_1+ a_2(\frac{q}{p})^n$ to be a solution.
But $0=P_0=a_1+a_2$ and $1=P_k=a_1+a_2(\frac{q}{p})^k$.
to get : $$a_2=\frac{1}{(\frac{q}{p})^k-1}$$.
SO then the solution is , for general settings, $$\frac{-1}{(\frac{q}{p})^k-1}+\frac{1}{(\frac{q}{p})^k-1}(\frac{q}{p})^k$$.
Right?