Random Number Generator
Generate random integers or decimals with customizable range, count, and duplicate control.
Generated Numbers
History (last 5)
What is a Random Number Generator?
A random number generator produces numbers within a specified range using a pseudo-random algorithm, giving you unpredictable picks on demand. It is useful for games, raffles, simulations, statistical sampling, and everyday decision-making — anywhere you want a choice made without bias or debate.
This generator lets you set a minimum and maximum, choose whole numbers or decimals, draw up to 100 values at once, and decide whether repeats are allowed. Every run is computed locally in your browser, which keeps a history of your last five runs. Each value in the range is equally likely, so over many runs the results form a uniform distribution.
How the Generator Works
Each draw starts from a fresh value random that is at least 0 and less than 1, supplied by Math.random(), then stretched and shifted onto your range:
Integer = floor(random × (Max − Min + 1)) + Min
Decimal = round(random × (Max − Min) + Min, 6 decimal places)
The integer formula keeps both endpoints reachable — Min and Max are inclusive — while decimals are stored at six-decimal precision and displayed rounded to four:
- Min — the lowest value in the range. In integer mode it can be picked; decimals always land between Min and Max.
- Max — the highest value. It must be greater than Min, and in integer mode it can be picked.
- Count — how many numbers to draw, from 1 to 100 per run.
- Type — Integer for whole numbers, Decimal for fractional values.
- Allow Duplicates — checked samples with replacement, so repeats are possible; unchecked forces unique values. Unique integers require Max − Min + 1 to be at least Count.
Worked Example: Six Unique Numbers from 1 to 49
Suppose you are drawing six winners in a lottery-style pick: Min = 1, Max = 49, Count = 6, Type = Integer, Allow Duplicates off. The range check gives 49 − 1 + 1 = 49 possible values, so six unique draws fit comfortably (49 ≥ 6).
The formula covers the whole range because random × (49 − 1 + 1) = random × 49 spans 0 up to, but not including, 49:
- random = 0 → floor(0 × 49) + 1 = 0 + 1 = 1, the minimum.
- random = 0.5 → floor(0.5 × 49) + 1 = floor(24.5) + 1 = 24 + 1 = 25.
- random = 0.999999 → floor(48.999951) + 1 = 48 + 1 = 49, the maximum.
Every integer from 1 through 49 is reachable, and each value has probability 1 ÷ 49 ≈ 0.020408, or 2.0408%, per draw. One sample run produced 1, 10, 35, 41, 43, 45. The sum is 1 + 10 + 35 + 41 + 43 + 45 = 175, a sample mean of 175 ÷ 6 ≈ 29.17 — above the theoretical average of (1 + 49) ÷ 2 = 25.0, which is normal for only six draws. The chance that one specific number, say 25, appears among the six unique picks is 6 ÷ 49 ≈ 0.122449, or 12.2449%.
Decimal mode skips the floor step: with Min = 0, Max = 1, and Count = 3, a sample run produced 0.3238, 0.1508, 0.6509 — each is random × (1 − 0) + 0 stored to six decimals (e.g. 0.323833) and shown rounded to four.
Chance of Any Specific Value per Draw
In integer mode the per-draw probability is 1 divided by the number of values in the range:
| Range | Values in Range | Chance per Draw |
|---|---|---|
| 1–2 (coin flip) | 2 | 50% |
| 1–6 (die) | 6 | ≈ 16.6667% |
| 1–10 | 10 | 10% |
| 1–49 (lottery-style) | 49 | ≈ 2.0408% |
| 1–100 | 100 | 1% |
| 1–1,000 | 1,000 | 0.1% |
How to Use
- Enter the lowest value you want in the Min field.
- Enter the highest value in the Max field — it must be greater than Min.
- Set Count to how many numbers you need, from 1 to 100.
- Choose Integer or Decimal in the Type dropdown.
- Leave Allow Duplicates checked to sample with replacement, or clear it for unique values.
- Click Generate. Results appear as chips, and the run joins the History panel, which keeps your last five runs. Click Reset to restore the defaults.
Frequently Asked Questions
Are the numbers truly random?
They are pseudo-random. The tool uses JavaScript's Math.random(), a deterministic algorithm that produces an unpredictable, evenly spread sequence — suitable for games, raffles, sampling, and decisions, but not for cryptographic keys or security draws, which need a cryptographic generator.
What is the difference between Integer and Decimal mode?
Integer mode returns whole numbers and includes both endpoints: a 1–6 range can return 1, 2, 3, 4, 5, or 6 with equal probability. Decimal mode returns fractions between Min and Max, stored at six-decimal precision and displayed rounded to four decimals.
Can I generate numbers without duplicates?
Yes — uncheck "Allow Duplicates." For integers the range must be large enough: Max − Min + 1 must be at least Count. Drawing 10 unique integers from 1–10 works, but 11 triggers the "range too small" error. Decimals are compared at six-decimal precision.
Why do I see repeats when duplicates are allowed?
That is normal for sampling with replacement — every draw is independent, so values can repeat. Repeats are more common than intuition suggests: 10 draws from 1–100 leave only about 9.56 distinct values on average.
How many numbers can I generate at once?
Up to 100 numbers in a single run. If you need more, generate again — the History panel keeps your last five runs so earlier batches stay visible.
Is this tool free?
Yes. BestCalc's random number generator is completely free, with no registration required. All calculations run locally in your browser, and your history never leaves the page.