A Deranged Gamble

Problem #107

Tags: puzzle statistics

Who solved this?

Previous:The Deranged Goats Next:Everyday Problems


Continuing from the previous problem with Gavin and his goats...

While we may like to believe that Gavin's problem is solved, the unfortunate reality is that he did not keep track of which blanket was given to each goat on the previous night, meaning that he must now re-distribute the blankets back to each goat randomly on the second night.

Gavin crosses his fingers, desperately hoping that no goat receives the same blanket twice so that he can get another good night's rest.

Problem Statement

If the N blankets are randomly redistributed among N goats on the second night, what is the probability that no goats will receive the same blanket as the previous night?

Input Data
First line is Q, the quantity of testcases.
Q lines then follow, each with a single integer N.

Answer
Should be Q space-separated decimals, corresponding to requested probability.
Error should be less than 1e-6.

Example

input data:
3
1
2
3

answer:
0 0.5 0.333333
You need to login to get test data and submit solution.