# Free online random number generator

> A random number generator picks numbers with equal probability across the range you set. Use it for games, lotteries, statistics sampling, or any time you need unbiased random.

Generate one or more random integers or decimal numbers within any range, with options to allow or prevent duplicate values.

**Interactive version:** https://onlinecalculator.me/everyday/random-number/
**Category:** Everyday

## How to use

1. Set the minimum and maximum values for your range.
2. Choose how many numbers to generate (1–100).
3. Select **Integer** or **Decimal** type.
4. Check or uncheck **Allow duplicates** as needed.
5. Click **Generate** to see your random numbers.

## How it works

Each number is drawn independently and uniformly from the range [min, max].

For integers without duplicates, the calculator uses a Fisher-Yates partial shuffle:
```
Place all integers min..max in a pool.
For each position i from 0 to count-1:
  pick random j from i..poolLength-1
  swap pool[i] and pool[j]
  use pool[i] as the next result
```

For decimals, each value is drawn as:
```
value = min + Math.random() × (max − min)
```
rounded to 2 decimal places.

## Common uses

- **Lottery or raffle draws** — pick 6 unique integers from 1–49 (disable duplicates).
- **Random sampling** — select 20 rows from a list of 500 by generating 20 unique integers from 1–500.
- **Game randomization** — initiative order, loot drops, event triggers.
- **A/B test assignment** — decide which variant a user sees by generating 1 integer from 1–2 (or 1–N).
- **Pick-one decisions** — "heads or tails" is 1–2; "which restaurant" is 1–N where N is your shortlist.

## Worked examples

### Lottery pick — 6 unique numbers from 1–49

- Min: 1, Max: 49, Count: 6, Type: Integer, Allow duplicates: **off**
- Sample output: 7, 12, 23, 31, 38, 44

### Pick a random winner from 250 entries

- Min: 1, Max: 250, Count: 1
- Output: 187 → entry #187 wins

### Monte Carlo test — 10 decimals between 0 and 1

- Min: 0, Max: 1, Count: 10, Type: Decimal
- Output: 0.34, 0.71, 0.12, 0.58, 0.94, 0.03, 0.46, 0.82, 0.27, 0.69

## Notes

- **Not cryptographically secure** — uses the browser's `Math.random()`, fine for lotteries, games, and sampling, but **not** for passwords, tokens, or anything where predictability could be exploited. Use `crypto.getRandomValues()` or a hardware RNG for security.
- For very large ranges (e.g., 1 to 1,000,000), duplicate integers are unlikely even when duplicates are allowed.
- The count is capped at 100 to keep results readable.
- Decimal mode always allows duplicates because repeating a specific two-decimal-place value from a wide range is rare.
- **Fair vs. uniform** — the generator is uniform: every value in the range has equal probability. "Random" doesn't mean each sequence "feels" random — a run of 7 7 7 is just as likely as 3 8 1 in a wide range.

## Frequently asked questions

### Are the numbers truly random?

The generator uses the browser's Math.random(), which is a pseudo-random number generator (PRNG). It produces numbers that are statistically uniform and unpredictable enough for everyday use — games, sampling, randomization — but not for cryptographic security. For cryptographic purposes, use a hardware-based generator.

### What does "allow duplicates" mean?

When duplicates are allowed, the same number can appear more than once. When disabled, each generated integer appears at most once. Duplicates cannot be disabled for decimal numbers because the probability of the same decimal repeating is effectively zero.

### Why does disabling duplicates sometimes give an error?

If you ask for more unique integers than exist in the range, it is impossible to comply. For example, generating 10 unique integers between 1 and 5 is impossible — there are only 5 values available.

### What is the difference between integer and decimal output?

Integers are whole numbers (no decimal point). Decimal results are shown with exactly two decimal places and can represent any value in the range, including fractional values.

### How do I share a fixed random seed?

This calculator does not support fixed seeds — each click generates a new result. Use Share with my numbers to share your range and count settings, not the specific numbers generated.

## Sources

- [Random number generation](https://en.wikipedia.org/wiki/Random_number_generation) — Wikipedia
- [Discrete uniform distribution — equal probability over a range of integers](https://en.wikipedia.org/wiki/Discrete_uniform_distribution) — Wikipedia

## Related calculators

- [Dice roller](https://onlinecalculator.me/everyday/dice/) — Roll polyhedral dice and calculate the probability of hitting a target number.
- [Combinations calculator](https://onlinecalculator.me/math/combinations/) — Count the number of ways to select items from a set.
- [Probability calculator](https://onlinecalculator.me/math/probability/) — Calculate probability for simple and compound events.
- [Average calculator](https://onlinecalculator.me/math/average/) — Find the mean, median, and mode of a list of numbers.

---

Part of [onlinecalculator.me](https://onlinecalculator.me/) — free calculators that run entirely in your browser.
Machine-readable index: https://onlinecalculator.me/llms.txt
