How many random integers from (1-n) must I produce to get all n integers
Assume a perfect random
Because of duplicates it will be more than n
I understand there will be variance but is there an upper bound?
From this program it is about (5 to 6) * n random to get n unique
It is same as the dice question. If I have an n sided dice how many rolls to get all n.
private static int Guesses()
{
Random rand = new Random();
int sample = 100;
int sum = 0;
HashSet<int> hs = new HashSet<int>();
for (int j = 0; j < sample * sample; j++)
{
hs.Clear();
do
{
hs.Add(rand.Next(sample));
sum++;
} while (hs.Count < sample);
}
Debug.WriteLine(sum / sample / sample);
return (sum / sample / sample / sample);
}