Suppose that integers in the range 1 through 100 are to be stored in a hash table using the hashing function h(i) = i % n, where n is the table's capacity.
Write a program that generates random integers in this range and inserts them into the hash table until a collision occurs.
The program should carry out this experiment 100 times and should calculate the average number of integers that can be inserted into the hash table before a collision occurs.
Run the program with various values for the table's capacity.