Solution (source code)

= Solution

The state-zero <stationary distribution> equation is $\pi_0=q\pi_0+q\pi_1$, so $\pi_1=(p/q)\pi_0$. The state-one equation is $\pi_1=p\pi_0+q\pi_2$, giving $\pi_2=(p/q)\pi_1$. More generally, the stationary <probability> flow across the cut $\{0,\ldots,i\}$ is balanced, so $p\pi_i=q\pi_{i+1}$. This also follows inductively from $\pi_i=p\pi_{i-1}+q\pi_{i+1}$.

Hence $\pi_i=(p/q)^i\pi_0$. Since $p<q$, the <geometric series> is summable, and normalization gives
$$
\boxed{\pi_i=\left(1-\frac pq\right)\left(\frac pq\right)^i,\qquad i\ge0.}
$$
These <probabilities> satisfy <detailed balance> and therefore all the stationarity equations. The <Markov chain> is an <irreducible Markov chain>, so this normalized <stationary distribution> is unique.