estimate the population numbers $100$ cookies labeled as $1$-$100$ numbers, and a cookie jar. The interviewer randomly selects a number between $1$-$100$ (say he selected $N$), and put cookies number $1$-$N$ to the jar. You randomly pick a cookie from the jar, it is labeled $5$, estimate how many cookies are in the jar.

Let $X \equiv $ cookie you picked. Note that:
$$
Pr(X=5 \mid N=n)=
\begin{cases}
0 & \text{if } n \in \{1,2,3,4\} \\
1/n & \text{if } n \in \{5,6,...,100\}
\end{cases}
$$
Hence, the expected number of cookies given that you picked one that was labelled $5$ is:
$$ \begin{align*}
E[N \mid X=5] &= \sum_{n=1}^{100} n \cdot Pr(N=n \mid X=5) \\
&= \sum_{n=1}^{100} n \cdot \dfrac{Pr(N=n)Pr(X=5 \mid N=n)}{Pr(X=5)} \\
&= \sum_{n=1}^{100} n \cdot \dfrac{Pr(N=n)Pr(X=5 \mid N=n)}{\sum_{k=1}^{100}Pr(N=k)Pr(X=5 \mid N=k)} \\
&= \sum_{n=5}^{100} n \cdot \dfrac{\dfrac{1}{100} \cdot \dfrac{1}{n}}{\sum_{k=5}^{100}\dfrac{1}{100} \cdot \dfrac{1}{k}} \\
&= \sum_{n=5}^{100} \dfrac{\dfrac{1}{100}}{\dfrac{1}{100}\sum_{k=5}^{100} \dfrac{1}{k}} \\
&= \sum_{n=5}^{100} \dfrac{1}{\sum_{k=5}^{100} \dfrac{1}{k}} \\
&= \dfrac{96}{\sum_{k=5}^{100} \dfrac{1}{k}} \\
&= 30.9274...
\end{align*}$$
