Random Number Generator - Generate Random Numbers & Lottery
Generate random numbers with custom range. Lottery number presets, duplicate control, and instant results.
About This Tool
The Random Number Generator produces random integers or decimals within a specified range. It supports single number generation, multiple numbers at once, and options for allowing or excluding duplicates. It is commonly used for lotteries, raffles, statistical sampling, gaming, and educational purposes.
How to Use
- Enter the minimum and maximum values to define your number range.
- Set how many numbers you want to generate (1-100).
- Choose whether to allow duplicates. For lottery-style picks, disable duplicates.
- Use lottery preset buttons to auto-fill settings for popular lotteries.
- Click 'Generate' to get your results instantly. Use the 'Copy' button to copy results to your clipboard.
Frequently Asked Questions
How does random number generation work?
This tool uses JavaScript's Math.random() function to generate pseudo-random numbers within your specified range. When duplicates are disallowed, it uses the Fisher-Yates shuffle algorithm to ensure evenly distributed unique numbers.
Can I use this for lottery numbers?
Yes! Use the lottery preset buttons to quickly generate numbers for Korean Lotto 6/45, US Powerball, Mega Millions, or EuroMillions. However, this tool is for entertainment purposes only and does not guarantee winning numbers.
What is the difference between allowing and disallowing duplicates?
When duplicates are allowed, the same number can appear multiple times. When disallowed, every generated number is unique. Choose 'no duplicates' for lottery-style picks where each number must be different.
How many numbers can I generate at once?
You can generate up to 100 random numbers at a time. In no-duplicates mode, the count cannot exceed the range size. For example, with a range of 1-45, you can generate at most 45 unique numbers.
Related Tools
How It Works
This generator uses the Web Crypto API (crypto.getRandomValues()) to produce cryptographically secure pseudo-random numbers, which are far more unpredictable than Math.random(). The Crypto API draws entropy from the operating system's random number source (e.g., /dev/urandom on Linux, CryptGenRandom on Windows).
To generate a random integer in the range [min, max], the algorithm creates a random 32-bit unsigned integer, then maps it to the desired range using modular arithmetic with rejection sampling to avoid modulo bias: a random value is discarded and regenerated if it falls in the biased remainder range.
For generating multiple unique numbers (no duplicates), the Fisher-Yates shuffle algorithm is used when the range is small relative to the count, or a Set-based rejection method when the range is large. This ensures uniform distribution — each possible outcome has an equal probability of being selected.