- Home
- Tools
- Generators
- Random Number Generator
Random Number Generator
Random numbers in any range, with or without repeats.
Press Generate to draw a number.
How the numbers are drawn
Every number comes from your browser's cryptographic random generator, the one that also makes encryption keys. Its output cannot be predicted from earlier results, which is not true of the ordinary generator that most programming languages offer by default.
Each value in your range is equally likely. That takes a little care. The browser hands out numbers from 0 to 4,294,967,295, and the obvious way to squeeze those into a range of, say, 1 to 6 is to divide and keep the remainder. But 4,294,967,296 is not a multiple of 6: four values are left over at the top, and they would make the faces 1 to 4 come up very slightly more often than 5 and 6. So the tool throws those leftover values away and draws again. This is called rejection sampling, and it leaves every face with a chance of exactly one in six.
Repeats, or not
With repeats allowed, each number is a fresh draw, like rolling a die: the same value can come up twice. With No repeats, a number that has been drawn is out, like balls taken from a lottery machine. Six numbers from 1 to 49 without repeats is one of 13,983,816 possible tickets, each as likely as the next.
You cannot draw more numbers without repeats than the range holds. From 1 to 10 there are ten, so asking for eleven gets you a message instead of a result. Asking for exactly ten gives all of them in random order, which is a quick way to shuffle a numbered list.
Decimals
With decimals, the tool draws from every value that has the number of decimal places you chose. Between 0 and 1 with two decimals there are 101 of them: 0.00, 0.01 and so on up to 1.00, all equally likely, both ends included. Many generators pick a number with many digits and round it, which makes each end only half as likely as the values in between.
Whole numbers work up to 1,000,000,000,000,000 in either direction. Each decimal place takes one digit off that.
Is this good enough for a real draw?
For a game, a classroom, a giveaway among friends or picking who goes first: yes. The numbers are as random as a computer can make them and nothing is sent to a server.
For a lottery or a contest with rules and money attached it is not, and no web page is. Nobody else can check afterwards that the number you announce is the one that came up, or that you pressed the button only once. An official draw needs witnesses or a published, verifiable procedure. The earlier draws listed under the result are only kept until you close or reload the page.
A random result also does not look "random" to most people. In a draw of six numbers from 1 to 49, two consecutive numbers turn up about half the time, and 1, 2, 3, 4, 5, 6 is exactly as likely as any other ticket.