Random Number Generator

Enter the minimum, the maximum, and how many numbers to draw. The calculator returns integers from the closed range {min, …, max}. With 1 and 6 and a count of 1 the result is one of six values (P = 1/6). With 6 numbers and no repeats from 1 to 49 each value appears at most once.

Inputs

Enter the minimum, the maximum, and how many numbers to draw. The range is closed: both ends can appear.

Result

Enter a range. The drawn numbers appear here.

This is not a lottery ticket and not a fortune wheel. The number of subsets is on the combinations page.

How it works

How the result forms for 1…6 with count 1
S{1,…,6}
n6
P1/6
X∈ S

The calculator draws integers from the closed interval from minimum to maximum. The outcome set is {min, min + 1, …, max} ⊂ ℤ. With minimum 1 and maximum 6 there are six values: 1, 2, 3, 4, 5, and 6. A count of 1 returns one of those values, each with probability 1/6. The next click draws again.

When you enter several numbers and leave repeats on, each place is independent (sampling with replacement). Three numbers from 10 to 20 can repeat the same value — that is not a range error; it is a property of the with-replacement model.

With no repeats the calculator builds a set without replacement: each value appears at most once. The calculator is a partial Fisher–Yates shuffle of the pool. Six numbers from 1 to 49 fit in n = 49. Ten numbers from 1 to 5 without repeats do not, because the range has only five places.

This is not a lottery ticket and not a fortune wheel. The numbers stay in the browser. Combinations C(n, k) count subsets; they do not pick which numbers appear.

When crypto.getRandomValues is available, the calculator maps CSPRNG bytes onto {0, …, n − 1} with rejection sampling to avoid modulo bias (unequal probabilities). When Web Crypto is unavailable, Math.random is used — then the result is not suitable for passwords or cryptography. The result panel shows which source was used. Minimum and maximum must be integers; 1.5 shows an error. A range from −10 to 10 includes zero.

The count is a value from 1 to 100. An empty field inserts 1. Absolute bounds are ±1,000,000,000. This is an educational tool, not a NIST laboratory and not an official draw.

Formula

n = max − min + 1, S = {min, min + 1, …, max}, P(X = s) = 1/n for s ∈ S.

One draw: sample U ∈ {0, …, n − 1} uniformly (CSPRNG + rejection sampling, otherwise Math.random), return min + U.

No repeats: a partial Fisher–Yates permutation of pool S, with m ≤ n.

Mathematical model: discrete uniform on [min, max] ∩ ℤ (Knuth TAOCP vol. 2; MDN crypto.getRandomValues; NIST SP 800-90 context — not a certificate for this page).

Theory, domain, and limits

Definition

Let min, max ∈ ℤ with min ≤ max. The range length is n = max − min + 1. The support set is S = {min, min + 1, …, max} = [min, max] ∩ ℤ. The discrete uniform distribution on S assigns each s ∈ S the probability P(X = s) = 1/n. This calculator draws one or more independent samples from S (with replacement) or samples without replacement when no repeats is checked.

For a single draw with minimum 1 and maximum 6 we have n = 6 and P(X = k) = 1/6 for k = 1, …, 6. That is the classic fair-die model on a finite integer set — not a continuous uniform on a real interval.

The outcome is random in the sense of the generator implemented in the browser, not in the sense of a paper proof about an infinite i.i.d. sequence. When bounds are extreme, check the integer domain first, then the ±10⁹ limit and the count limit of 100.

Historical and conceptual context

Donald E. Knuth in The Art of Computer Programming, Volume 2 (Seminumerical Algorithms), treats computer “random” numbers carefully: deterministic PRNG sequences versus ideal randomness, tests, and pitfalls when carrying bits onto a finite range. Modern browsers also expose a CSPRNG through the Web Crypto API (crypto.getRandomValues), documented on MDN and in the W3C specification.

NIST publishes guidance for deterministic generators and entropy sources in the SP 800-90 series (including 800-90A for DRBGs). This page does not claim NIST certification: it uses the browser API and honestly separates CSPRNG from Math.random. NIST documents provide conceptual context (what cryptography demands), not a quality seal for this calculator.

Conceptually separate: (1) the mathematical model — discrete U(S); (2) the bit source — CSPRNG or PRNG; (3) the map from bits onto S — here rejection sampling to avoid modulo bias (unequal probabilities). Fortune wheels, lotteries, and official draws are separate legal and hardware procedures.

Formal properties

For X uniform on S: E[X] = (min + max)/2, Var(X) = (n² − 1)/12. The mass function is constant on S and zero outside S. With m independent draws with replacement, (X₁, …, Xₘ) has a product distribution; repeated values are allowed.

With m ≤ n and sampling without replacement, the result is a uniformly chosen ordered m-tuple from S (draw order), equivalent to a partial permutation. The number of ordered m-tuples without repeats is P(n, m) = n!/(n − m)!. When m > n the event is impossible — the calculator reports an error instead of inventing a result.

The identity n = max − min + 1 is exact in integer arithmetic within the ±10⁹ limit. Shifting the range (min + c, max + c) leaves n and uniformity on the new set unchanged.

Full derivation

Step 1. Read integers min, max and count m ∈ {1, …, 100}. Reject fractions and min > max.

Step 2. Compute n = max − min + 1. For one draw choose U ∈ {0, …, n − 1} uniformly, then return min + U.

Step 3 (CSPRNG). Read a 32-bit value from crypto.getRandomValues. Let M = 2³² and L = ⌊M / n⌋ · n. Reject samples ≥ L, then take the remainder modulo n. Each residue 0…n−1 then has equal probability (no modulo bias when n does not divide M).

Step 4 (fallback generator). When Web Crypto is unavailable: U = ⌊Math.random() · n⌋. ECMAScript does not guarantee cryptographic quality for Math.random.

Step 5 (no repeats). Build the pool [min, …, max] and run m steps of partial Fisher–Yates: at index i draw j ∈ {i, …, n − 1}, swap, append pool[i].

Step 6. Example: min = 1, max = 6, m = 1 → one of six values with P = 1/6. min = 1, max = 49, m = 6, no repeats → six distinct values from 1…49.

Special cases

min = max: n = 1, the only possible value is that shared bound; without repeats only m = 1 is allowed. Range −10…10: n = 21, zero is included. m = 100 on a small n with replacement is allowed; without repeats requires n ≥ 100.

An empty count field inserts m = 1. Values outside ±10⁹ or non-integer input produce an error instead of silent truncation.

The result is not a sequence tested by Diehard/TestU01 — it is a single educational draw in the browser.

Numerical notes

Math.random returns a Number in [0, 1) and is not intended for secrets (passwords, tokens, keys). Even with a CSPRNG, simply taking the remainder x % n introduces slight bias when n does not divide 2³² — hence rejection sampling in this calculator.

For very large n (order 10⁹) a no-repeats pool would consume too much memory; the limits m ≤ 100 and |min|,|max| ≤ 10⁹ keep the tool practical in a browser. The result panel shows n, P = 1/n, and the source label (Web Crypto or the fallback generator).

Do not use this page for digital signatures, legal lotteries, or production password generation. For cryptography use dedicated APIs and procedures aligned with current guidance (e.g. the NIST SP 800-90 context), not an interactive educational calculator.

Related concepts and sources

Related: combinations C(n, k) (subset counts), permutations, modulo (remainder, not a draw), continuous uniform (a different model). To count ways use the combinations page; here the result is concrete numbers.

Sources: Knuth, TAOCP vol. 2 — Seminumerical Algorithms (random numbers chapter); NIST SP 800-90A Rev. 1 (DRBG — context, not a certificate for this page); MDN — Crypto.getRandomValues; Wikipedia — Discrete uniform distribution; W3C Web Cryptography API.

How to use it

  1. Enter the minimum and the maximum, for example 1 and 6.
  2. Leave 1 in the count field when you need one value.
  3. Click Draw. The result is an integer from 1 to 6 inclusive (P = 1/6).
  4. When you want several distinct numbers, enter the count and turn on no repeats. From 1 to 49 with a count of 6 the set does not repeat a value.
  5. Check the panel for length n, P = 1/n, and the bit source. This is not a lottery — compare the result with your own rule.

Symbol glossary

With 1 and 6 the range length n is 6, and the probability of one value in a single draw is 1/6.

min, max
Integer bounds of the range. Both ends can appear. With 1 and 6 the set has six elements.
n
Range length max − min + 1. For 1…6 it is 6. For 10…20 it is 11.
S
The set {min, …, max}. A single draw lands in S.
P
Probability 1/n for each value in one draw with replacement.
m
How many numbers to draw (1…100). An empty field inserts 1.
CSPRNG
Bit source from crypto.getRandomValues when available. The browser’s ordinary generator (Math.random) is only a fallback.

Examples

Example 1

  • Minimum 1, maximum 6
  • Count: 1
  • Repeats allowed

one integer from 1 to 6 (P = 1/6)

n = 6. One value from S. The next click draws again.

Example 2

  • Minimum 1, maximum 49
  • Count: 6
  • No repeats

6 distinct integers from 1 to 49

n = 49. Six values without replacement. Not a lottery ticket.

Example 3

  • Minimum 10, maximum 20
  • Count: 3
  • Repeats allowed

three integers from 10 to 20 (n = 11)

Three independent integers. The same value can return.

Example 4

  • Minimum −10, maximum 10
  • Count: 1
  • Repeats allowed

one integer from −10 to 10 (n = 21)

Zero is in the set. P = 1/21.

Example 5

  • Minimum 1, maximum 5
  • Count: 10
  • No repeats

error: m > n

Without repeats you cannot draw 10 from five places.

Example 6

  • Minimum 5, maximum 5
  • Count: 1
  • Repeats allowed

always 5 (n = 1)

Singleton: the only possible value is the shared bound.

Related calculators

Frequently asked questions

What does an inclusive range from minimum to maximum mean?

The range is closed: both ends belong to the set. With minimum 1 and maximum 6 the possible values are 1, 2, 3, 4, 5, and 6. The range length is n = max − min + 1.

How does the no-repeats option work?

With no repeats the generator samples without replacement: each value appears at most once. The count cannot exceed n = max − min + 1. Asking for 10 numbers from a range of length 5 shows an error.

Is the result cryptographically secure?

When the browser exposes crypto.getRandomValues, the calculator uses CSPRNG bytes with rejection sampling to avoid modulo bias (unequal probabilities). This is not a NIST SP 800-90 certificate, not a randomness laboratory, and not an official state draw. If Web Crypto is unavailable, Math.random is used as a fallback — then the result is not suitable for passwords or cryptography.

How is this different from Math.random?

Math.random in ECMAScript is not defined as a CSPRNG and must not be used for secrets. This page prefers crypto.getRandomValues and shows in the result panel which source was actually used. The browser’s ordinary generator (Math.random) remains only as an emergency fallback.

Is this a fortune wheel or a lottery?

No. The generator returns integers from the range you enter. It does not place a bet, spin a wheel, or run an official lottery draw.

Do negative numbers and zero work?

Yes. A range from −10 to 10 includes zero and both sides of zero. Minimum cannot be greater than maximum. Only integers are accepted.

Why does a fraction like 1.5 show an error?

The model is a discrete uniform distribution on the integer set {min, …, max}. Fractions are outside the domain. Enter integers, for example 1 and 6.

How many numbers can I draw at once?

From 1 to 100. An empty count field inserts 1. With no repeats the range length n is an additional limit.

How is this different from combinations C(n, k)?

Combinations count how many k-element subsets exist from n elements. Here the result is the drawn numbers themselves, not the number of ways.

What is the probability of one value in a single draw?

Under a uniform draw with repeats allowed, each value in {min, …, max} has probability 1/n, where n = max − min + 1. From 1 to 6 that is 1/6.

With 1 and 6 and a count of 1 the result is one of six values (P = 1/6, n = 6). Subset counts are on the combinations page.

Sources

Definitions and caveats below come from recognized sources and no fake cryptographic certificates.

Page updated October 14, 2026.