Solution (source code)

= Solution

The state space is $\{0,1,\ldots,N\}$. In this increasing ordering, the <transition matrix> is specified by
$$
\boxed{P_{00}=1,\qquad P_{kj}=\frac1k\ (k\geq1,\ 0\leq j<k),\qquad P_{kj}=0\text{ otherwise}.}
$$
For each positive $k$, the $k$ possible amounts taken correspond bijectively to the $k$ possible remaining counts. Each positive-state row therefore sums to one.