Random Number Generator

Set the range, set how many you need, and decide whether values may repeat, the difference between rolling a die and drawing a raffle.

With or without replacement

This is the setting that decides whether your result is correct. Rolling a die is drawing with replacement: every roll is independent and a six can follow a six. Drawing raffle tickets is without replacement: once a number comes out it cannot come out again. Using the wrong one is a real error, not a preference, a raffle that can draw the same ticket twice is not a raffle, and a dice simulator that never repeats a value is not simulating dice. The no-repeats toggle is that choice, and the tool caps the count at the size of the range when it is on, because you cannot draw ten distinct values from a range of five.

How the no-repeats draw works

For a range up to ten thousand values, the tool builds the full range and shuffles it, then takes the first n. That guarantees termination and a uniform result. The obvious alternative, drawing at random and discarding repeats, gets slower and slower as the set fills up, and drawing 9,999 distinct values from a range of 10,000 that way spends most of its time rejecting numbers it has already seen. For very large ranges the reservoir approach is used instead, because building a list of ten million numbers to pick three would be wasteful.

Frequently asked questions

Should I turn on no repeats?

Yes for a raffle, a shuffle or any draw where a value cannot come out twice. No for dice, simulations or anything where each draw is independent.

Why can I not get more numbers than my range allows?

With no repeats on, distinct values cannot exceed the size of the range. Asking for ten from a range of five is impossible, so the count is capped.

Is this suitable for something with money at stake?

Use a properly audited draw for anything of real value. This uses the standard JavaScript random source, which is fine for games and sampling but is not a certified draw.