TR

Home / Guides / How Are Random Numbers Generated? Range Mapping, Repeat Probability and Fair Draws

How Are Random Numbers Generated? Range Mapping, Repeat Probability and Fair Draws

Updated: November 6, 2026 · AracMerkezi

▶ Open Random Number Generator

We need random numbers to hold a draw, set a duty order, roll a die in a game or generate test data. If the randomness is not reliable, the result can be unfair. In this guide, we show with calculations how a computer produces a random number, how that number is turned into a range such as "between 1 and 100," the probability of the same number coming up again, and how many different outcomes a draw can have.

How are random numbers generated?

Computers provide randomness in two ways:

The tools on this site use the browser's secure random number generator.

A random number in a given range

You set the smallest and largest whole numbers and write how many numbers you want. For example, you can ask for 5 numbers between 1 and 100. The end values are included; the same number can come up more than once.

Example 1: Mapping a number between 0 and 1 to a range

The generator gives a raw number between 0 and 1 (1 excluded). The formula to turn it into an integer range is: result = minimum + floor(r × (maximum − minimum + 1)). If the range is 1–100, the number of elements is 100.

  1. r = 0.5 → 1 + floor(0.5 × 100) = 1 + 50 = 51.
  2. r = 0 → 1 + 0 = 1 (lower end).
  3. r = 0.999 → 1 + floor(99.9) = 1 + 99 = 100 (upper end).

The formula includes the end values too. The most common mistake is forgetting the "+ 1" part: if you multiply by 99 instead of 100, the number 100 never appears.

Example 2: Why does the remainder operation cause a slight bias?

Generators often give a large 32-bit integer and map it to the range with a remainder (mod) operation. Let's see the logic with a small example: suppose there are 256 equally likely values from 0 to 255, and we map the result to 0–99 with the remainder after dividing by 100. Since 256 = 2 × 100 + 56:

So some numbers are 1.5 times as likely as others. With 32-bit values there are 2³² = 4,294,967,296 values; divided by 100 that leaves 42,949,672 full rounds and a remainder of 96, so 96 results come up one more time than the others. The relative difference is about 1 / 42,949,672 ≈ 2.3 × 10⁻⁸. The tool on this site uses the remainder operation; in small ranges such as 1–100, the bias is practically negligible, but the larger the range, the more noticeable the difference becomes. Software that wants to remove the bias discards values above the limit and draws again.

Example 3: Can the same number come up again?

If you generate 5 numbers between 1 and 100 and each draw is independent, the probability that all the numbers are different is: (100/100) × (99/100) × (98/100) × (97/100) × (96/100) ≈ 0.9035. So the probability that at least one number repeats is about 9.65%. When you ask for 10 numbers, this probability rises to about 62.8%. Although it seems against intuition, repeats are normal in random series; if you want results without repeats, use the draw tool.

Drawing lots

Write the candidates one per line and set how many people to choose. The tool picks without repeats. For example, you can choose 3 people from among 20.

Example 4: What are the odds when choosing 3 from 20?

Every triple is equally likely; that is, the chance of any particular triple is 1 / 1,140 ≈ 0.088%. If you need a ranking (1st prize, 2nd prize), announce in advance that the order the tool produces will be the prize order.

Tips for a fair draw

Dice, coin flips and other uses

For a die, you can generate a number in the range 1–6, and for a coin flip a number in the range 1–2. In games and entertainment, the result depends entirely on chance. For probability interpretations, see the guide to dice rolls and coin flips; for permutation and combination logic, the factorial and combination guide is useful.

A warning about official draws

Promotional, prize or public draws are subject to regulation and may require supervision by a notary or an authorized institution. This tool is for entertainment and everyday use; it is not a substitute for draws with legal validity.

Use for security purposes

For generating passwords, keys or security tokens, prefer dedicated tools; for example, the password generator uses secure randomness. Do not use values made with a simple random number for security.

Common mistakes

  1. Interpreting a number not coming up for a long time as "its turn has come"; each draw is independent.
  2. Forgetting the "+ 1" and leaving out the upper end.
  3. Using the random number tool when you want results without repeats; the draw tool picks without repeats.
  4. Using a simple random generator for security values.
  5. Not announcing the draw rules in advance.

When to use it and its limits

It is suitable for everyday decisions, picking in class, games and test data. Randomness does not have to be repeatable; that is, if you run the same draw again you will not get the same result. If you need a reproducible result (for example, re-creating a scientific simulation), you use a generator whose starting value can be fixed; this tool is not like that.

Try the Random Number Generator and Random Draw / Selection tools. For a secure password, the Password Generator, and for ID generation, the UUID Generator can be used.

Frequently asked questions

Is the random number generator reliable?

The tool uses the browser's secure random number generator; it is suitable for entertainment and everyday use.

Can the same number come up more than once?

In random number generation, yes; in a draw, the candidates are chosen without repeats.

Can it be used in an official draw?

No; draws with legal validity may require supervision by a notary or an authorized institution.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.