Premium problem94. Coupon Collector

Medium Locked

Draw uniformly at random from m categories with replacement. Return the expected number of draws needed before you have seen every one.

Split the wait into stages. Once you hold i distinct categories, each draw is new with probability (m−i)/m(m-i)/m, so that stage takes m/(m−i)m/(m-i) draws on average:

E=m∑i=1m1iE = m \sum_{i=1}^{m} \frac{1}{i}

The last few coupons dominate: collecting the final one alone takes m draws.

Input

10

Output

29.289682539682538

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)