Airplane Seat Assignment Probability
n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. After that, the rest of the passengers will:
- Take their own seat if it is still available.
- Pick another seat randomly when they find their seat occupied.
Return the probability that the n^th person gets his own seat.
Example 1
Input
n = 1Output
1The first person can only get the first seat.
Example 2
Input
n = 2Output
0.5The second person has a probability of 0.5 to get the second seat, which happens when the first person gets the first seat.
Constraints
- 1 <= n <= 10^5