Random Number Generator

Random Number Generator

Popular AI Skill PRO

Enter Calculation

Formula

xi=Min+⌊rand()×(Max−Min+1)⌋i=1…Countx_i = \text{Min} + \left\lfloor \text{rand}() \times \left( \text{Max} - \text{Min} + 1 \right) \right\rfloor \quad i = 1 \dots \text{Count}
Usage stats

Advertisement

Results

Your Random Number
52
Range: 1 – 100
First number 52
Numbers generated 1
Possible values (range size) 100

Report an error on this page

What is a random number generator?

A random number generator (RNG) produces unpredictable numbers within limits you choose. This tool generates random integers between a minimum and a maximum value (both inclusive). You can draw a single number or many at once, and you can decide whether repeated values are allowed. It's handy for raffles and giveaways, picking lottery-style numbers, choosing a winner from a list, assigning teams, dice and game rolls, sampling, or any time you need an impartial pick.

How to use it

Enter the Minimum and Maximum of your range, set How many numbers you want (1–100), and choose whether to allow duplicates. If you turn duplicates off, the generator returns only distinct values — and if you ask for more numbers than the range can supply, it automatically caps the count to the number of available values.

Flat diagram of the random number formula mapping a 0-to-1 random value into an integer range
The formula maps rand() (0 to 1) onto the integer range and floors the result.

The formula explained

For one integer the tool uses $$x_i = \text{Min} + \left\lfloor \text{rand}() \times \left( \text{Max} - \text{Min} + 1 \right) \right\rfloor$$ where \(\text{rand}()\) is a uniform fraction in [0, 1). Multiplying by the range size \(\left( \text{Max} - \text{Min} + 1 \right)\) and flooring gives an offset from 0 up to range−1, which is then added to \(\text{Min}\). This makes every integer in the inclusive interval equally likely. To draw several numbers the process simply repeats; when duplicates are disallowed, picked values are removed from the pool so they cannot recur.

Advertisement

Worked example

Suppose you want 3 unique numbers between 1 and 6. The range size is $$6 - 1 + 1 = 6$$ The generator picks from {1,2,3,4,5,6}, removing each chosen value, so you might get 4, 1, 6 — three different numbers, never repeating. With duplicates allowed you could instead see something like 4, 4, 1.

Diagram showing random selection of an integer from a range between min and max on a number line
A random number generator picks a value uniformly between the chosen min and max.

Common Range and Count Scenarios

The range size is \(N = \text{Max} - \text{Min} + 1\) (both ends are included). On a single fair draw, each integer in the range has probability \(\frac{1}{N}\). With duplicates allowed, every draw has this same probability. With unique values, each later draw is made from the values that remain, so its probability becomes \(\frac{1}{N-1}\), \(\frac{1}{N-2}\), and so on. The table shows the first-draw probability.

Min Max Count Duplicates Range size (Max − Min + 1) Values returned Probability of any one value on one draw (1/range size)
1 6 1 Allowed 6 1 1/6 ≈ 16.67%
1 6 3 Unique only 6 3 1/6 ≈ 16.67% on the first draw
1 10 5 Unique only 10 5 1/10 = 10% on the first draw
1 100 10 Allowed 100 10 1/100 = 1% on every draw
1 5 10 Unique only 5 5 (capped at the range size) 1/5 = 20% on the first draw

Without duplicates you cannot draw more distinct numbers than the range contains. In the last row, asking for 10 unique numbers from 1–5 can return at most 5, which is every value in a shuffled order. If you need more results than the range size, allow duplicates or widen the range.

Advertisement

FAQ

Are the numbers truly random? They are pseudo-random — generated by a software algorithm that is statistically uniform and more than sufficient for games, draws and everyday picks, but not for cryptography.

Are min and max included? Yes. Both endpoints can be produced; the interval is inclusive on both ends.

What if min is larger than max? The values are swapped automatically so the range still makes sense.

Last updated:

Most popular in Miscellaneous

View all Miscellaneous calculators