Solution (source code)

= Solution

Put $D=1-(1-p)(1-q)=p+q-pq$. By the <law of total probability>,
$$
\begin{aligned}
\mathbb P(Y=k)
&=\sum_{n=k}^{\infty}p(1-p)^n\binom nkq^k(1-q)^{n-k}\\
&=p[(1-p)q]^k\sum_{n=k}^{\infty}\binom nk[(1-p)(1-q)]^{n-k}.
\end{aligned}
$$
For $0\leq t<1$, termwise differentiation of the <geometric series>, valid inside its <radius of convergence>, gives
$$
\sum_{n=k}^{\infty}\binom nk t^{n-k}
=\frac1{k!}\frac{d^k}{dt^k}\frac1{1-t}
=\frac1{(1-t)^{k+1}}.
$$
Taking $t=(1-p)(1-q)$ therefore yields
$$
\boxed{\mathbb P(Y=k)=\frac pD\left(\frac{(1-p)q}{D}\right)^k,\qquad k\geq0.}
$$
Since $D-p=(1-p)q$, this is the zero-based <geometric distribution> with parameter
$$
\boxed{p_* =\frac{p}{p+q-pq},\qquad \mathbb P(Y=k)=p_*(1-p_*)^k.}
$$
This illustrates <Bernoulli thinning of a geometric count>. Here $0<p_*<1$, as $0<p,q<1$.

For the reverse <conditional distribution>, <Bayes' theorem> gives, for $n\geq k$,
$$
\begin{aligned}
\mathbb P(X=n\mid Y=k)
&=\frac{p(1-p)^n\binom nkq^k(1-q)^{n-k}}
{p[(1-p)q]^k/D^{k+1}}\\
&=\binom nk[(1-p)(1-q)]^{n-k}D^{k+1}.
\end{aligned}
$$
Thus
$$
\boxed{\mathbb P(X=n\mid Y=k)=h_{n,k}(r),\qquad r=D=p+q-pq.}
$$
For $n<k$ the <conditional probability> is zero. The <conditional distribution> of $X-k$ is the failure-count form of a <negative binomial distribution>, with $k+1$ successes and success parameter $r$: the <geometric-binomial posterior is shifted negative binomial>.