Coupons
Time limit1sMemory limit128 MB
Compute the expected number of purchases needed to collect all N coupon numbers, printing the result as an integer or reduced mixed fraction.
- Level
Medium4 of 10
- Topics
- Probability, Math, Number theory
- Solved
- No attempts yet
Problem
A chicken box comes with one coupon. Each coupon has one number from 1 through N, and every number is equally likely on each purchase.
Haebin wants to order a Gold Cheese Chicken. To do that, Haebin must collect every coupon numbered 1 through N. For each given N, determine the expected number of chicken boxes Haebin must order.
Input
Several values of N are given, one per line, until end of file.
Each value satisfies 1 <= N <= 22.
Output
For each input value, print the expected number of chicken boxes.
If the answer is an integer, print that integer. Otherwise, print its integer part, followed by one space and the remaining fractional part as a reduced fraction in the aligned format shown below. Do not print unnecessary spaces.