By · Updated

Random Number Generator

Pick Fair Random Numbers in Any Range

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Random Number Generator works

This random number generator picks whole numbers between any lowest and highest value you set, including both ends. Draw one number for a quick decision or up to a thousand for a raffle, a sample or a game, with or without repeats, and sort the list if you want it in order.

How the random number generator works

Each number comes from crypto.getRandomValues(), the browser's cryptographic random source, not from Math.random(). A 32-bit random value is mapped onto your range with rejection sampling: values that would make some numbers slightly more likely than others are thrown away and redrawn, so every number in the range has exactly the same chance. The formula for the chance of any one number is 1 ÷ (max − min + 1). With repeats allowed, each draw is independent. With "No repeats" the tool draws without replacement, which is how a raffle or a ball machine works.

First example. Pick one number from 1 to 100. There are 100 − 1 + 1 = 100 possible results, so each has a 1 in 100 chance, and the expected mean over many draws is (1 + 100) ÷ 2 = 50.5.

Second example. Draw 23 numbers from 1 to 365 with repeats allowed. This is the birthday problem: the chance that at least two draws match is 1 − (365 × 364 × … × 343) ÷ 365²³, which is just over 50 percent. Repeats turn up far sooner than most people expect.

How many numbers can you draw without repeats? At most the size of the range: from 1 to 10 you can draw 10 different numbers and no more. The tool tells you if you ask for more than the range holds.

Chance that k draws with repeats allowed contain at least one duplicate

Draws (k) From 1–100 From 1–365 From 1–1,000 From 1–10,000
2 1% 0.274% 0.1% 0.01%
3 2.98% 0.8204% 0.2998% 0.03%
5 9.655% 2.714% 0.9965% 0.09997%
10 37.18% 11.69% 4.414% 0.4491%
15 66.87% 25.29% 10.01% 1.045%
20 86.96% 41.14% 17.41% 1.883%
23 93.57% 50.73% 22.5% 2.5%
25 96.24% 56.87% 26.1% 2.958%
30 99.22% 70.63% 35.55% 4.261%
40 99.99% 89.12% 54.64% 7.513%
50 Over 99.99% 97.04% 71.23% 11.55%
57 Over 99.99% 99.01% 80.35% 14.78%
60 Over 99.99% 99.41% 83.57% 16.25%
70 Over 99.99% 99.92% 91.57% 21.5%
80 Over 99.99% 99.99% 96.11% 27.16%
100 Over 99.99% Over 99.99% 99.4% 39.14%
118 Over 99.99% Over 99.99% 99.92% 49.99%
150 Over 99.99% Over 99.99% Over 99.99% 67.47%
200 Over 99.99% Over 99.99% Over 99.99% 86.51%
300 Over 99.99% Over 99.99% Over 99.99% 98.92%
500 Over 99.99% Over 99.99% Over 99.99% Over 99.99%
1000 Over 99.99% Over 99.99% Over 99.99% Over 99.99%

Tips and pitfalls

Use "No repeats" for raffles, prize draws and picking participants, because nobody should win twice. Keep repeats on for simulations such as dice, where the same result can genuinely come up again. If you need decimals, generate a whole number and divide, for example 1 to 1000 divided by 100 for two decimal places.

FAQ

Is this random number generator truly random?

It uses the browser's cryptographic random generator, which is seeded from hardware noise and is the same source used for encryption keys. Results cannot be predicted from earlier draws, and rejection sampling removes the small bias a plain modulo would add.

Can I generate random numbers with no repeats?

Yes. Choose "No repeats" and every number in the list will be different, as in a raffle where each ticket leaves the hat once drawn. You can draw as many numbers as the range contains and no more.

How do I pick a random number between 1 and 10?

Set the lowest number to 1 and the highest to 10, leave the count at 1 and press Generate. Both ends are included, so 1 and 10 can each come up with a one in ten chance.

Can the random numbers be negative?

Yes. Set a negative lowest number, such as −50 to 50, and the tool includes every whole number in between, zero included. The same formula applies: the chance of each number is one over the size of the range.

Why did the same number come up twice in a row?

With repeats allowed, each draw is independent and has no memory of the last one. A repeat is normal and becomes likely surprisingly fast, as the birthday-problem table shows. Choose "No repeats" if a number must never appear twice.

See also: all Lists & Lines tools, Writing & Editing, Markdown & HTML, Ciphers & Alphabets.

Related tools