Premium problem90. Every Bucket Gets Something

Hard Locked

Throw n objects independently and uniformly into m buckets. Return the probability that no bucket is left empty.

Inclusion-exclusion over which buckets are missed:

P=∑j=0m(−1)j(mj)(m−jm)nP = \sum_{j=0}^{m} (-1)^j \binom{m}{j}\left(\frac{m-j}{m}\right)^{n}

The alternating signs matter: subtracting "bucket 1 empty" and "bucket 2 empty" removes the case where both are empty twice, so it has to come back.

Input

n = 10
m = 3

Output

0.9480262155159275

Premium problem

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

Implement solve(...)