Draw a set of random integers from a configurable inclusive range, optionally without duplicates — a general-purpose random integer sampler for games, giveaways, and statistics exercises.
Algorithm
Given from, to, and numberToExtract:
- Validate that both bounds are integers and
from ≤ to. - If duplicates are disallowed, require that the range width (
to − from + 1) is at least as large as the requested count. - Repeatedly draw a uniform random integer in
[from, to]until the requested count is reached; when duplicates are off, reject draws already present in the result set.
Results are sorted ascending for readability.
When to use it
Pick random winners for a small giveaway, generate practice datasets for a statistics class, simulate dice-style draws for a game night, or teach probability with reproducible random draws (via the programmatic API seed options in development).
Limitations
Randomness uses the environment's pseudo-random generator — fine for casual games and demos, not for cryptographic or high-assurance certification. Very large ranges with many extractions and no duplicates can approach performance limits as rejection sampling repeats internally.
Example
With from = 1, to = 90, and numberToExtract = 6 with duplicates off, the tool returns six ascending integers drawn from the 1–90 range, for example 4 17 29 41 63 88.