Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int sum = 0;
- int a = 37;
- int trials = 10000;
- int[] list = new int[trials];
- for (int i = 0;i<trials;i++){
- int[] check = new int[a];
- int times = 0;
- boolean done = false;
- for (int j = 0;j<check.length;j++){
- check[j] = j+1;
- }
- while (!done){
- int prng = (int) (Math.random()*check.length);
- check[prng] = 0;
- times++;
- done = true;
- for (int j = 0;j<check.length;j++){
- if (check[j] != 0) done = false;
- }
- }
- sum += times;
- list[i] = times;
- }
- double average = sum/trials;
- System.out.println(average);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement