Home / Math Calculators / Random Number Generator

Math & Statistics

Random Number Generator

Generate one or many random numbers in any range. Choose integers or decimals, and allow or forbid duplicate values.

Your random numbers

Count—
Sum—

Generated values

Each generated number, shown for a quick visual comparison.

How it works

The generator uses your browser's built-in pseudo-random function to pick numbers uniformly across the range you set, inclusive of both ends. With "unique values" on, it draws without replacement so no number repeats.

integer = floor( random × (max − min + 1) ) + min
decimal = random × (max − min) + min

Using random numbers fairly

Every whole number in the range has the same chance, 1 ÷ (max − min + 1). Picking from 1 to 100 gives each number a 1% chance, and drawing 6 unique numbers from 1 to 49 can produce 13,983,816 different combinations, the same odds as a classic 6/49 lottery.

For a raffle, number the tickets, generate one value per prize with repeats turned off, and record the results before you reveal them. The generator uses your browser's standard random function, which is fine for games, classroom picks and giveaways; for security keys or regulated lotteries use a cryptographically secure source such as the password generator, which uses the Web Crypto API.

Popular ways to use a random number generator

UseSettings
Roll a dieMin 1, max 6, one number
Flip a coinMin 1, max 2 (1 = heads, 2 = tails)
Pick a raffle winnerMin 1, max = number of tickets, unique values on
Choose 3 people from a class of 30Min 1, max 30, count 3, unique values on
Random percentageMin 0, max 100, decimals on

How many combinations are possible?

When order doesn't matter and numbers can't repeat, the number of possible draws is n! ÷ (k! × (n − k)!), written "n choose k".

DrawCombinationsOdds of one exact set
3 from 101201 in 120
5 from 52 (a poker hand)2,598,9601 in 2,598,960
5 from 6911,238,5131 in 11,238,513
6 from 4913,983,8161 in 13,983,816

Randomness is streakier than you expect

Shuffling, random order and team assignment

To put a list into random order, such as a presentation order, a tournament seeding or a playlist, set the minimum to 1, the maximum to the number of items, How many to the same number, and turn on unique values. The result is a random permutation: read it as "item 7 goes first, item 2 second" and so on. Every possible order is equally likely.

To split 24 people into 4 teams of 6, number them 1 to 24 and generate all 24 unique values. The first six numbers form Team A, the next six Team B, and so on. This is fairer than letting captains pick, and quicker than drawing names from a hat.

Simple random samples for surveys and audits

A simple random sample gives every member of a group the same chance of being chosen. That's the basis of most statistics. To survey 50 customers out of a list of 1,200, sort the list in any fixed order, generate 50 unique numbers from 1 to 1,200, and contact the customers in those rows. Auditors use the same method to choose invoices to check, and teachers use it to pick work to moderate. Write down the numbers before you look at the list, so nobody can say the sample was chosen by hand.

Dice, sums and why the shape changes

One die gives a flat distribution: each face from 1 to 6 has a 1 in 6 chance. Adding dice changes that. Rolling two dice and adding them is not the same as picking a number from 2 to 12:

ResultTwo dice (2d6) addedSingle pick from 2–12
2 or 122.8% each (1 in 36)9.1% each (1 in 11)
4 or 108.3% each (3 in 36)9.1% each
716.7% (6 in 36)9.1%

To simulate a board game correctly, generate two numbers from 1 to 6 with duplicates allowed and add them. For tabletop role-playing dice, set the maximum to 4, 8, 10, 12 or 20 for a d4, d8, d10, d12 or d20.

How often will a number repeat?

With duplicates allowed, repeats turn up sooner than most people expect. Drawing 10 numbers from 1 to 100 gives a 37% chance that at least one number appears twice. Drawing 30 gives a 99% chance. The general rule is 1 − n! ÷ ((n − k)! × nᵏ) for k draws from n values. It's the same maths as the birthday problem above. If a repeat would spoil your use, such as giving one person two prizes, turn on unique values.

Pseudo-random vs cryptographically secure

Browsers' Math.random() uses a fast pseudo-random algorithm that is statistically uniform but predictable in principle. crypto.getRandomValues() draws from the operating system's secure entropy source and is designed to be unpredictable, which is why it is used for passwords and encryption keys.

Frequently asked questions

Are these numbers truly random?

They are pseudo-random from your browser, plenty random for games, raffles, and sampling, but not for cryptography.

Can I avoid duplicates?

Yes, enable "unique values" and every result is different, provided the range is large enough.

What are the odds of a specific number?

One divided by the number of values in the range. From 1 to 50, each number has a 1 in 50 (2%) chance on a single draw.

How many ways can you pick 6 numbers from 49?

13,983,816 combinations when order does not matter and numbers do not repeat.

How do I pick a random winner fairly?

Number every entry, set the range from 1 to the total number of entries, turn on unique values, and generate one number per prize. Record or screenshot the result before announcing it.

How do I put a list in random order?

Set the range from 1 to the number of items, generate that many numbers with unique values on, and use the results as the new order.

What does n choose k mean?

The number of ways to choose k items from n when order doesn't matter: n! ÷ (k! × (n − k)!). For 6 from 49 that is 13,983,816.

Related calculators