Random Number Generator

Generate random integers or decimals within any custom range.
Set min, max, count, and decimal places for lottery picks, dice rolls, raffles, and sampling.

Generated Numbers

Random number generation uses algorithms to produce values that appear statistically unpredictable within a defined range. Understanding the underlying math helps you use random numbers correctly in games, decisions, sampling, and simulations.

Core formula (integer generation): Random Integer = Math.floor(Math.random() × (max − min + 1)) + min

Where:

  • Math.random() generates a pseudo-random float ≥ 0 and < 1
  • (max − min + 1) scales the range to include both endpoints
  • Math.floor() converts the float to a whole number
  • + min shifts the result to your desired starting value

Probability of any single value: P(x) = 1 ÷ (max − min + 1)

For a 1–100 range: P(any number) = 1/100 = 1% per value

Common use cases and their settings:

Use Case Min Max Notes
Coin flip 0 1 0 = tails, 1 = heads
Standard die 1 6 Each face ~16.67%
D20 (tabletop RPG) 1 20 Each value 5% probability
Lottery draw (6 of 49) 1 49 Count 6, and set no repeats
Random team picker 1 N N = number of teams

Expected value (multiple rolls): For a fair die (1–6), the expected value = (1+2+3+4+5+6)/6 = 3.5 For a 1–100 range, expected average = 50.5

Worked example, picking a raffle winner from 80 entrants: Set min = 1, max = 80, count = 1. Each entrant has a 1/80 chance, which is 1.25%. Whoever holds that number wins.

To draw three winners rather than one, set count = 3 and switch “Allow the same number twice” to No. With repeats allowed you can genuinely draw ticket 47 three times, which is correct probability and useless as a raffle.

Draws with and without replacement

This is the distinction the setting controls, and it changes the odds:

  • With replacement (dice, coin flips, simulations): every draw is independent and the same value can come up again. Rolling a six does not make the next six less likely.
  • Without replacement (lottery balls, raffle tickets, splitting people into teams): each value comes out once. The odds shift with every draw, because the pool shrinks.

Ask for more numbers than the range holds without replacement and there is nothing to draw, so the calculator gives you the whole range shuffled instead.

Decimals

Set decimal places above zero and the generator switches to a continuous range rather than whole numbers, useful for simulations and test data. Repeats become effectively impossible at that point, so the no-duplicates setting stops applying.

Important limitation: Math.random() is a pseudo-random generator. Entirely adequate for games, raffles, sampling and simulation, and not for anything security-sensitive. Passwords, tokens and keys need crypto.getRandomValues(), which draws on real system entropy.

One last thing worth knowing, because it comes up every time someone tests a generator: truly random output looks streakier than people expect. Four heads in a row from twenty coin flips is completely ordinary. A run that never repeats and never clusters is the suspicious one.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.