이 로또 시스템에서는 1부터 49까지의 숫자 풀에서 10개의 숫자가 무작위로 추첨됩니다. 플레이어는 5개의 숫자를 선택하며, 추첨된 숫자와 일치하는 개수에 따라 상금이 지급됩니다.
이는 큰 상금이 매우 희귀한 반면, 작은 당첨은 상대적으로 더 자주 발생하는 흥미로운 역동성을 만듭니다.
5개 숫자 중 정확히 k개 숫자를 맞출 확률 P(k)는 다음과 같이 계산됩니다:
여기서:
• C(n,k)는 조합 (n개 요소에서 k개 요소를 선택하는 방법의 수)을 나타냅니다.
• 5는 플레이어가 선택한 숫자 개수입니다.
• 10은 추첨된 당첨 숫자 개수입니다.
• 49는 가능한 총 숫자 개수입니다.
P(k) = [C(5,k) × C(44,10-k)] / C(49,10)
P(3) = [C(5,3) × C(44,7)] / C(49,10)
= (10 × 38,608,020) / 8,217,822,536
≈ 386,080,200 / 8,217,822,536
≈ 0.04698 ≈ 21.28분의 1
P(4) = [C(5,4) × C(44,6)] / C(49,10)
= (5 × 7,059,052) / 8,217,822,536
≈ 35,295,260 / 8,217,822,536
≈ 0.004295 ≈ 233분의 1
P(5) = [C(5,5) × C(44,5)] / C(49,10)
= (1 × 1,086,008) / 8,217,822,536
≈ 1,086,008 / 8,217,822,536
≈ 0.000132 ≈ 7,566분의 1
P(당첨) = P(3) + P(4) + P(5)
≈ 0.04698 + 0.004295 + 0.000132
≈ 0.0514 ≈ 19.45분의 1
이는 플레이어가 어떤 상금이든 당첨될 확률이 약 5.14%임을 의미합니다.
/**
* Generates an array of unique random integers within a specified range in sorted order.
*
* Performed daily for draws with parameters of generateUniqueRandomSortedIntegers(10, 1, 49)
*
*
* @param {number} count - The number of unique integers to generate (must be positive)
* @param {number} min - The lower bound of the range (inclusive)
* @param {number} max - The upper bound of the range (inclusive)
* @returns {number[]} A sorted array of unique random integers
* @throws {Error} If the requested count exceeds the possible unique values in the range
* or if any parameter is invalid
*/
function generateUniqueRandomSortedIntegers(count, min, max) {
// Validate input parameters
if (!Number.isInteger(count) || !Number.isInteger(min) || !Number.isInteger(max)) {
throw new Error("All parameters must be integers");
}
if (count <= 0) {
throw new Error("Count must be a positive integer");
}
if (min > max) {
throw new Error("Minimum value cannot exceed maximum value");
}
const rangeSize = max - min + 1;
if (count > rangeSize) {
throw new Error(`Cannot generate ${count} unique numbers in range [${min}, ${max}]`);
}
// For small ranges relative to count, use Fisher-Yates shuffle algorithm
if (count > rangeSize / 2) {
const allNumbers = Array.from({length: rangeSize}, (_, i) => min + i);
// Fisher-Yates shuffle
for (let i = allNumbers.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[allNumbers[i], allNumbers[j]] = [allNumbers[j], allNumbers[i]];
}
return allNumbers.slice(0, count).sort((a, b) => a - b);
}
// For larger ranges relative to count, use Set approach
const uniqueNumbers = new Set();
while (uniqueNumbers.size < count) {
const randomNumber = Math.floor(Math.random() * rangeSize) + min;
uniqueNumbers.add(randomNumber);
}
return Array.from(uniqueNumbers).sort((a, b) => a - b);
}