Draw random integers from a configurable inclusive range, optionally without duplicates — the same mechanism used for lottery-style number picks and statistical sampling demos.
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
Run small raffles, simulate lottery tickets, create practice data sets, or teach probability concepts with reproducible random draws (via the programmatic API seed options in development).
Limitations
Randomness uses the environment’s pseudo-random generator — fine for games and demos, not for cryptographic or high-stakes gambling certification. Very large ranges with many extractions and no duplicates can approach performance limits as rejection sampling repeats.
Legal disclaimer
This tool does not operate any licensed lottery. It cannot guarantee fairness in regulated gambling contexts. Organizers of paid drawings should follow local gaming laws and use audited randomness where required.