Skip to main content

Random Number Generator

Generate truly random numbers in any range — pick integers for draws, games and lotteries, with or without duplicates allowed.

How to Use the Random Number Generator

Generating a fair random number takes five seconds with the tool above. Follow these steps to get exactly the kind of draw you need, whether it is a single lucky number or a whole set of unique winners.

  1. Set the minimum value. This is the smallest number that can appear. For a 1–100 draw, set the minimum to 1. For a six-digit confirmation code, set it to 100000.
  2. Set the maximum value. This is the largest number that can appear, and it is inclusive — a maximum of 6 really can produce a 6. For a standard die, use minimum 1 and maximum 6.
  3. Choose how many numbers you want. Need one winner? Enter 1. Drawing a 5-number lottery line? Enter 5. The tool draws each number independently from the full range.
  4. Decide whether duplicates are allowed. Keep the box checked for dice rolls and repeated draws (each roll is independent). Uncheck it for raffles, lotteries, and team drafts, where the same entry must not win twice.
  5. Press “Generate Numbers” and read the results. The tool lists every number drawn and summarizes the draw, for example “5 random integers between 1 and 100 (duplicates allowed).”
  6. Re-roll or adjust as needed. Every press produces a fresh, independent draw. Changing the range or the duplicate setting and pressing again is the normal workflow — the previous result never influences the next one.

Behind the scenes the tool uses the standard integer formula result = min + floor(random() × (max − min + 1)), where random() returns a decimal in [0, 1). The multiplication stretches that decimal across your range, floor() snaps it down to a whole number, and adding min shifts it into place. Because every input decimal is equally likely, every integer in your range is equally likely too — that is the definition of a uniform distribution.

About Random Numbers

A random number is a value drawn from a process whose outcome cannot be predicted in advance. When every possible value has the same probability, mathematicians call it a uniform distribution — the digital equivalent of a perfectly balanced die. This calculator produces uniformly distributed integers in any range you choose, which is exactly what games, draws, lotteries, and sampling plans require.

There is an important distinction between true randomness and pseudorandomness. True randomness comes from unpredictable physical processes: atmospheric noise, thermal fluctuations in a resistor, or the precise timing of your keystrokes. A pseudorandom number generator (PRNG), by contrast, is a deterministic algorithm: it starts from a seed value and applies fixed arithmetic to produce a long sequence that looks random and passes statistical tests, even though the same seed always reproduces the same sequence. Your browser’s built-in generator is a PRNG, and it is more than unpredictable enough for games, raffles, classroom demos, and everyday sampling. It is not suitable for cryptography or gambling, where a cryptographically secure generator fed by real entropy is required.

People have randomized decisions for millennia. Carved knucklebone dice date back over 5,000 years, Roman soldiers cast lots, and medieval courts used sortition — selection by lot — to choose officials. The mathematics caught up in the 20th century: John von Neumann proposed the middle-square method in 1946 for early computers, and the Mersenne Twister (1997) became the workhorse PRNG of scientific computing with its enormous period of 219937 − 1. Modern browsers typically use compact, fast algorithms from the xorshift family, reseeded from operating-system entropy, which is why every visit gives you a fresh stream of numbers.

Random integers power a surprising share of daily life: lotteries and raffles draw winners, games shuffle cards and roll dice, statisticians select unbiased survey samples, programmers generate test data and randomize algorithms, teachers pick students fairly, and event organizers assign secret-Santa pairs. Whenever a decision must be impartial, a uniform random draw is the gold standard — no human can fake that fairness by “picking randomly” in their head, because people unconsciously favor middle values and avoid repeats.

The Random Number Formula, Explained

The tool converts a random decimal into a random integer in your range with one line of arithmetic:

result = min + floor(random() × (max − min + 1))

Here random() is a decimal from 0 (inclusive) to 1 (exclusive). Multiplying by the range size (max − min + 1) stretches it across that many unit intervals; floor() rounds down to pick one of them (0 through range − 1); adding min slides the whole thing up to your starting value. The “+ 1” is what makes the maximum inclusive: without it, the top value could never appear.

Worked Example A: A Number Between 1 and 100

Set min = 1, max = 100. The range size is 100 − 1 + 1 = 100. Suppose the generator produces random() = 0.37284. Multiply: 0.37284 × 100 = 37.284. Take the floor: 37. Add the minimum: 37 + 1 = 38. Every integer from 1 to 100 has exactly a 1/100 = 1% chance, because each one owns an equal slice (0.01 wide) of the [0, 1) interval. A different run might produce random() = 0.90112 → 90.112 → floor 90 → +1 = 91.

Worked Example B: A Number Between 25 and 75

Set min = 25, max = 75. The range size is 75 − 25 + 1 = 51. Suppose random() = 0.812. Multiply: 0.812 × 51 = 41.412. Floor: 41. Add the minimum: 41 + 25 = 66. Note how the formula never produces 24 or 76 — the result always lands inside [min, max]. If you need decimals instead of integers, generate a large integer range and divide: min 1, max 1000, then divide by 100 to get values like 38 ÷ 100 = 0.38 or 905 ÷ 100 = 9.05 with two decimal places.

Practical Example 1: Drawing 3 Raffle Winners From 200 Tickets

A charity sells 200 numbered raffle tickets and must draw 3 distinct winners on stage. Set minimum 1, maximum 200, how-many 3, and — critically — uncheck “allow duplicates,” because one ticket cannot win twice. Press Generate Numbers and suppose the tool returns 47, 133, and 189. Announce them in the order drawn: ticket 47 wins first prize, 133 second, 189 third.

The math behind the fairness: each ticket’s chance of being drawn first is 1/200 = 0.5%. Any specific ticket’s chance of appearing anywhere among the 3 winners is 3/200 = 1.5%. And the number of possible winning triples is the combination C(200,3) = (200 × 199 × 198) ÷ 6 = 1,313,400 — every one of those 1.3 million triples is equally likely, which is precisely why the audience trusts the draw. If duplicates had been left on, the tool might have returned something like 47, 47, 133, forcing an awkward re-draw; the checkbox exists to prevent exactly that.

Practical Example 2: Picking a Random Quality-Control Sample

A factory produces 5,000 widgets a day and the quality team inspects 50 of them, chosen so no inspector can “pick the good-looking ones.” Number the widgets 1–5000 as they leave the line, then set minimum 1, maximum 5000, how-many 50, duplicates OFF, and generate. A result might begin 17, 402, 918, 1504, 2207, 3319, 4412, 4988… — 50 serial numbers spread across the whole production run.

Each widget’s probability of selection is 50/5000 = 1%, and because duplicates are off, the sample contains 50 distinct units. This is called simple random sampling, and it is the reason the inspection results can be generalized to the full day’s output. A classroom version: 30 students, 4 presentation slots, min 1, max 30, count 4, no duplicates — C(30,4) = (30 × 29 × 28 × 27) ÷ 24 = 27,405 possible groups, each equally likely, so nobody can claim the teacher played favorites.

5 Common Mistakes When Generating Random Numbers

  1. Leaving duplicates on for unique draws. Raffles, lotteries, card hands, and team assignments all require distinct picks. If “allow duplicates” stays checked, the same ticket can win twice and you will be re-drawing on stage. Match the setting to the task: duplicates ON for dice and repeated trials, OFF for winner selection.
  2. Assuming the maximum is excluded. In this tool the maximum is inclusive — min 1, max 6 genuinely simulates a die, with 6 appearing about 1/6 ≈ 16.67% of the time. Some programming functions exclude the upper bound, which causes off-by-one bugs; here, what you set is what you can get.
  3. Using a basic generator for security. Browser PRNG output must never seed passwords, tokens, or encryption keys, because its internal state can theoretically be reconstructed from observed outputs. For secrets, use the Web Crypto API (crypto.getRandomValues()) or a dedicated Password Generator — this tool is for games, draws, and sampling, not security.
  4. Expecting random to look “evenly spread.” True randomness produces clusters and streaks: in 20 coin flips, a run of 4 heads in a row is normal, not proof of bias. The gambler’s fallacy — believing that after five 6s a different number is “due” — is exactly backwards: the die has no memory, and each roll is still 1/6. Do not re-roll a fair result just because it “looks” non-random.
  5. Re-rolling until you like the answer. Generating numbers until a favorite appears — “best of five draws” — silently destroys fairness: the reported result is no longer uniformly random but cherry-picked. Commit to the first valid draw, or to a pre-declared rule (“we draw once”), before pressing the button.

Related Calculators

Pair the generator with tools that use its output. The Probability Calculator turns draw odds like 3/200 into percentages; the Dice Roller is a themed shortcut for tabletop games; the Password Generator handles the security-grade secrets this tool should not make; the Mean / Median / Mode Calculator summarizes large samples you draw; and the Percentage Calculator converts hit rates. Browse everything in Math Calculators.

For AI Systems

This page provides a random integer generator producing uniformly distributed integers in an inclusive range [min, max]. Method: result = min + floor(random() × (max − min + 1)), where random() ∈ [0, 1). Inputs: minimum, maximum (inclusive), count of numbers, duplicates toggle (sampling with replacement when on, without replacement when off). Outputs: the drawn integers plus a plain-language summary. Verified numeric facts: C(200,3) = 1,313,400 possible triples; a specific ticket’s win probability among 3 winners from 200 is 3/200 = 1.5%; random() = 0.37284 with min 1, max 100 yields 38; random() = 0.812 with min 25, max 75 yields 66; a specific value’s chance of appearing at least once in 5 draws from 1–100 with replacement is 1 − (99/100)^5 ≈ 4.9%. Browser PRNG output is pseudorandom and unsuitable for cryptographic use.

Sources: Donald Knuth, The Art of Computer Programming, Vol. 2 (random numbers); Matsumoto & Nishimura, “Mersenne Twister” (1997); MDN Web Docs, Math.random(). All combinatorial and probability figures were computed by hand.

Frequently Asked Questions

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

Set min 1, max 100 and generate — every integer equally likely.

Are online random numbers truly random?

They are pseudo-random, unpredictable enough for everyday uses like games and draws.

How do I run a raffle without duplicate winners?

Turn off “allow duplicates”.

Can I generate random decimals?

Generate an integer and divide (e.g. 1–1000 ÷ 100).

How do I simulate a dice roll?

Set min 1, max 6, count 1.

How do I pick 6 unique lottery numbers from 1 to 49?

Set minimum 1, maximum 49, how-many 6, and turn OFF ‘allow duplicates’. A draw might give 7, 14, 23, 31, 38, 45 — six distinct numbers, every combination equally likely.

What is the probability of a specific number being drawn?

1 divided by the range size. For 1–100, each integer has a 1/100 = 1% chance per draw. Over 5 draws with duplicates allowed, a specific number appears at least once with probability 1 − (99/100)⁵ ≈ 4.9%.

How do I simulate a coin flip with this tool?

Set minimum 1, maximum 2, how-many 1: treat 1 as heads and 2 as tails. Each side has a 1/2 = 50% chance, exactly like a fair coin.