tryFunc(50000000); function tryFunc(tryCount) { let total = 0, min = Number.MAX_VALUE, max = 0; for(let i = 0; i < tryCount; i++) { let v = calc(); if(v < min) min = v; if(v > max) max = v; total += v; } console.log('min: ' + min, 'max: ' + max, 'avg: ' + total/tryCount); }; function calc() { let array = (new Array(35)).fill(0).map((v, i) => i + 1), count = 0; while(array.length !== 0) { let number = getRandomInt(1, 36); if(array.includes(number)) { array.splice(array.indexOf(number), 1); } count++; } return count; }; function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; //최댓값은 제외, 최솟값은 포함 }