Solution (source code)

= Solution

Write $H_k=\sum_{j=1}^k1/j$, with $H_0=0$. The truncated uniform <prior> gives the <posterior distribution>
$$
p(N\mid y,M)=\frac{N^{-1}}{H_M-H_{y-1}},\qquad y\leq N\leq M.
$$
Its <posterior mean> is
$$
\boxed{\mathbb E[N\mid y,M]=\frac{M-y+1}{H_M-H_{y-1}}.}
$$
Each term in the numerator of the expectation is $N/N=1$, which explains the exact count $M-y+1$.