Math

Random number generator

A random number generator picks numbers from a range so that every number has the same chance of being chosen. This tool generates one or many random whole numbers between any minimum and maximum, with or without repeats, using your browser’s cryptographically secure random source.

Runs in your browser. Nothing you type is sent to us.

Result

…

Key facts

  • Every whole number in the range, including both ends, has an equal chance of being picked.
  • Tick No repeats to draw unique numbers, like pulling raffle tickets from a hat.
  • Numbers come from the Web Crypto API, the same random source browsers use for encryption keys.
  • The chance of picking any one number from 1 to 100 is 1 in 100, or 1%.

How the random number generator works

Set a minimum and a maximum, choose how many numbers you want and decide whether repeats are allowed. Each press of the button draws a fresh set. Both the minimum and the maximum can be picked. The draw happens on your device and nothing is sent to a server.

Is it truly random?

Computers usually produce pseudo-random numbers from a formula. This tool uses crypto.getRandomValues, a cryptographically secure generator seeded from unpredictable hardware events. It also uses rejection sampling, which avoids the small bias that simple "random number modulo range" code introduces. For games, raffles, classroom picks and sampling, that is more than enough. For regulated lotteries or scientific studies with legal requirements, use a certified generator and keep an audit trail.

Common uses

UseSettings
Roll a dieMin 1, max 6, 1 number
Pick a raffle winner from 250 ticketsMin 1, max 250, 1 number
Choose 6 lottery-style numbers from 49Min 1, max 49, 6 numbers, no repeats
Shuffle a list of 30 studentsMin 1, max 30, 30 numbers, no repeats
Flip a coinMin 0, max 1 (0 = heads, 1 = tails)
Random sample of 20 from a list of 500Min 1, max 500, 20 numbers, no repeats

Probability of a draw

With repeats allowed, each number has a probability of 1 ÷ (max − min + 1) on every draw. Without repeats, the number of possible ordered draws of r numbers from n is n! ÷ (n − r)!, and the number of possible sets is n! ÷ (r! × (n − r)!). For 6 numbers from 1 to 49 there are 13,983,816 possible sets, so any one ticket has about a 1 in 14 million chance. The permutation and combination calculator works these out for any n and r.

Worked example: picking names fairly

You have 12 names on a list and need 3 volunteers. Number the names 1 to 12, set the range to 1 to 12, ask for 3 numbers and tick No repeats. If the result is 4, 11 and 7, the 4th, 11th and 7th names are chosen. Every group of three was equally likely: there are 220 possible groups.

Common mistakes with random numbers

  • Expecting randomness to look even. In 10 coin flips, getting 7 heads is not unusual (about a 12% chance). Streaks happen.
  • The gambler's fallacy. A number that has not appeared for a while is no more likely to come up next.
  • Asking for more unique numbers than the range holds. You cannot draw 20 unique numbers from 1 to 10.
  • Off-by-one ranges. 1 to 10 contains 10 numbers; 0 to 10 contains 11.

How computers make random numbers

Computers are deterministic, so most "random" numbers are produced by pseudorandom number generators, formulas that produce sequences that look random. John von Neumann proposed the early middle-square method in the 1940s, and the widely used Mersenne Twister, published by Makoto Matsumoto and Takuji Nishimura in 1998, has a period of 2¹⁹⁹³⁷ − 1. Before computers were common, scientists used printed tables: the RAND Corporation published *A Million Random Digits with 100,000 Normal Deviates* in 1955, generated with an electronic roulette wheel.

For anything that must be unpredictable, such as passwords, encryption keys and draws, generators are seeded with physical randomness. Cloudflare famously films a wall of about 100 lava lamps in its San Francisco office as one source of entropy, and modern processors include hardware random number instructions. Browsers expose a cryptographically secure generator through the Web Crypto API, standardized by the W3C, which is what this tool uses. A subtle trap is modulo bias: squeezing a random 32-bit number into a range with the remainder operator makes some numbers slightly more likely, so this generator discards and redraws values that would cause it. For secure passwords, use the password generator; to count possible draws, the permutation and combination calculator; and to summarize results, the average calculator.

How this calculator works

  • Uses the browser’s cryptographically secure generator (crypto.getRandomValues), not Math.random.
  • Rejection sampling removes modulo bias, so every whole number in the range is equally likely.
  • Generates 1 to 1,000 whole numbers between your minimum and maximum (inclusive), with an option for no repeats.
  • Nothing is sent to a server; each draw happens in your browser.

Frequently asked questions

How do I pick a random number between 1 and 10?

Set the minimum to 1 and the maximum to 10, ask for one number and press Generate. Each number from 1 to 10 has a 10% chance.

Can I generate random numbers without repeats?

Yes. Tick "No repeats" and every number in the result will be different, as long as you ask for no more numbers than the range contains.

Are the numbers really random?

They come from your browser’s cryptographically secure random generator with unbiased sampling, so they are unpredictable and evenly distributed for all practical purposes.

Can I use this for a giveaway or raffle?

Yes, for informal draws. Take a screenshot of the result for transparency. Regulated lotteries need certified equipment.

How do I flip a coin with this tool?

Set the range from 1 to 2 and decide in advance which number means heads.

Can it generate decimals or negative numbers?

It generates whole numbers. Negative ranges work, for example −50 to 50. For decimals, generate a larger range and divide, for example 1 to 1000 divided by 100 gives two decimal places.

What are the odds of picking the same number twice in a row?

With repeats allowed, the chance that the second number matches the first is 1 divided by the size of the range: 1 in 100 for the range 1 to 100.

Is the result saved anywhere?

No. Numbers are created on your device and are not stored or sent anywhere.

Sources

  1. MDN Web Docs, Crypto.getRandomValues()
  2. Wolfram MathWorld, Random Number

Updated November 25, 2026. Formulas checked against published sources and worked examples.

Cite this page: CalcRoster. "Random number generator." calcroster.com/random-number-generator/. Updated November 25, 2026.

Results are estimates for general information. They are not financial, medical or legal advice. Check important decisions with a qualified professional.