Skip to contentSkip to the inputSkip to the result

Random number generator

Pick 1 to 100 integers inside an inclusive range, with or without repeats, sorted or not, leaving out numbers you choose.

Loading tool

Instructions

Random number generator

How to use

  1. Enter the minimum and maximum and generate numbers.

Supported input

  • Integer bounds from −1 trillion to 1 trillion; up to 1,000 numbers to leave out.
  • Six of 1–45 never repeats a number.

Input example

1 to 100

Result example

A cryptographically random integer from 1 to 100

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • Pick 1 to 100 integers inside an inclusive range, with or without repeats, sorted or not, leaving out numbers you choose.

Picking whole numbers evenly: modulo bias and why some draws are thrown away

Where it comes in handy

  • Choosing who presents first, or which of 30 exercises to set, without arguing about it
  • Drawing seat numbers while skipping the seats that are already taken
  • Picking five winning raffle tickets out of 1–200 with no ticket drawn twice
  • Generating a column of random numbers for a statistics class to tally by hand

The modulo trap

A computer’s random source hands out numbers from zero up to just below a power of two. Taking the remainder after dividing by the size of your range looks like the obvious fix, but it favours some results. Use a random byte (0–255) modulo 6 as a die and, because 256 is not a multiple of 6, faces 0–3 turn up 43 times in 256 while 4 and 5 turn up only 42 times.

This tool asks the browser’s crypto.getRandomValues for a 32-bit number and throws it away if it falls at or above the largest multiple of the range size that fits in 2^32. What remains maps onto every result the same number of times, so the bias is gone. For 1–45 a redraw happens about 7 times in a billion; for a range three billion wide about 30% of draws are discarded, and the answer is still even. Ranges wider than 2^32 use 53 bits from two numbers in the same way: across −1 trillion to 1 trillion only about 0.013% are thrown away.

There is also a reason it avoids Math.random, the usual JavaScript shortcut. Math.random is fast but makes no promise of being cryptographically secure, and in some implementations its past outputs can be used to predict the next ones. For a prize draw, where someone might want to know the result in advance, an unpredictable source is the right choice.

How “no repeats” and excluded numbers work together

When a number on your exclusion list comes up, the draw is simply discarded and made again. That removes the excluded values without nudging the odds of any other number. With No repeats chosen, a number that has already been drawn is discarded the same way, and drawing continues until there are enough different values.

Combine the two and you can draw at most the size of the range minus the excluded numbers inside it. Drawing three different numbers from 1–20 with 4 and 13 excluded returned 1, 14, 19 in one run. Asking for five numbers from 1–5 with 3 excluded fails with a message that the range does not hold enough numbers, since only four are left. One special case: six numbers from 1–45 are always drawn without repeats, lottery style, even if repeats are allowed. There are 8,145,060 possible sets of six.

Allowing repeats means you will see them

With repeats allowed, each number is drawn independently, so duplicates are normal rather than a glitch. The chance that ten draws from 1–10 are all different is just 0.036%; one real run came out as 4, 2, 4, 9, 1, 6, 10, 5, 10, 1, with three values twice. Even five draws from 1–100 contain a repeat about 9.7% of the time, the same arithmetic as the birthday problem.

For anything where a ticket or a person must not win twice, choose No repeats. Keep repeats for jobs that really are independent each time, like rolling the same die again and again. Sorting the results smallest first changes only the order they are shown in, not which numbers were drawn.

What it is not for

  • Official lotteries or draws with legal weight, which need records, witnesses and certified equipment rather than one click on a screen.
  • Reproducible sequences. There is no seed, so the same numbers cannot be generated twice. Copy or save a result as soon as you get it.
  • Decimals or other distributions such as a bell curve. It draws whole numbers evenly and nothing else.
  • Drawing names. If the entries have names, the list draw picks them directly, which avoids mistakes in matching numbers to people.

Checked

Frequently asked questions

Can I draw 6 different numbers from 1 to 45?

Yes. Set min 1, max 45, count 6 and No repeats. Up to 100 numbers per draw; if the range holds fewer whole numbers than the count, you get an error.

Is the result truly random?

It uses the browser's Web Crypto randomness, with rejection sampling to remove range bias, so every whole number in the range is equally likely. The same number coming up twice in a row is normal.

Can I use decimals or a huge range?

No decimals. Both ends must be whole numbers from −1 trillion to 1 trillion; wide ranges draw 53 random bits, so even across the whole −1 trillion to 1 trillion span every whole number is equally likely. Both ends can be drawn.