I want to take samples from this discrete probability distribution of $n$, which I think is defined as:
$$\Pr(n=i) = p^i (1-p)$$
where $p$ is the probability of success in each independent Bernoulli trial. I.e. the number of consecutive successful binomial trials before the first unsuccessful one (or vice versa).
If $n$ were finite then this would be easy because I could calculate $Pr(n=i)$ for all $n$ and then sample from it.
I'm assuming this is a well-known distribution with software tools and I just don't know it's name.