Random Number Generator
This random number generator draws whole numbers from an inclusive minimum-to-maximum range after you press Calculate. It uses your browser’s Web Crypto random source with rejection sampling, while the server-rendered calculator output stays deterministic and contains no generated draw.
By Dr. Hassan Khames EliwaLast updated
How it works
Define the sample space explicitly
Both endpoints belong to the range. A minimum of one and maximum of six therefore permits six different integers, including one and six themselves. Each draw is made with replacement, meaning a value may appear repeatedly in the same batch. This tool does not shuffle a list or guarantee unique winners. Choose a count from one to one hundred and whole-number bounds within negative one billion and positive one billion.
The definition module only validates inputs and reports the number of possible integers, the requested count, and an instruction to calculate. It never reads a random source. The custom interface initially renders the same instruction on the server and in the browser, then requests randomness only from the form submission handler. Editing inputs clears the old batch so that values generated for earlier bounds are not displayed as if they belonged to the new range.
Avoid remainder bias
Web Crypto supplies unsigned 32-bit words. Simply taking every word modulo the range size can favor some remainders when that size does not divide 2³² evenly. The sampler instead calculates the largest multiple of the range size that fits within the 2³² possible words. It discards words at or above that limit, then maps each accepted remainder into the requested interval.
This rejection method gives every permitted integer the same number of accepted source words. A safety cap prevents a broken injected source from looping forever. If Web Crypto is unavailable or throws an error, the interface reports failure and does not substitute Math.random or a time-based seed. The sampling helper accepts supplied words for reproducible tests, but the actual interface obtains those words exclusively through getRandomValues inside Calculate.
Worked example
Example 1: demonstrate a die-sized range
Enter minimum 1, maximum 6, and count 3. The stable calculator summary reports 6 possible integers and 3 requested draws. For a test fixture supplying words 4,294,967,295, 0, 5, and 8, the first word is rejected because it falls in the incomplete remainder tail. The accepted words map to 1, 6, 3. These are deterministic fixture results, not a prediction of what a live browser will generate.
Example 2: include negative values
Enter minimum −2, maximum 2, and count 4. The summary reports 5 possible integers and 4 requested draws. Test words 0, 4, 7, and 9 map to -2, 2, 0, 2. The repeated two is intentional: replacement permits duplicates. A live Calculate action can return any permitted sequence, so exact production values should never be used as a pass-or-fail test of randomness.
Expert tips
Common mistakes
- A tiny batch cannot establish whether a generator is uniform. Runs and duplicates are possible in a uniform process; a visually tidy sequence is not a necessary sign of better randomness.
- An integer list is not a ready-made password, token, or cryptographic key. Security protocols need appropriate formats, sufficient entropy, and careful handling beyond sampling a user-chosen numeric interval.
- Redrawing an inconvenient outcome changes the selection procedure. Selective retries change the effective procedure even when every underlying browser draw uses a sound random source.
Frequently asked questions
Are the minimum and maximum included?
Yes. The range is inclusive at both ends. Equal endpoints are permitted and produce that same integer on every draw, because the sample space then contains only one value.
Why do repeated numbers appear?
Draws use replacement. Each new draw uses the same full interval, and earlier results are not removed. A unique-selection tool would need a different sampling policy.
Will refreshing the page generate a batch?
No. Initial rendering and input validation are deterministic. Randomness is requested only after submitting Calculate, not during server rendering, hydration, or ordinary input changes.
What happens if Web Crypto is unavailable?
The widget displays an error without falling back to a weaker source. A supported browser on a secure connection is the appropriate environment for the intended interface.
Can I reproduce a previous live draw?
Not from a seed entered into this tool. The test helper can reproduce fixtures with supplied words, but live Web Crypto draws are not exposed as a seeded pseudorandom sequence.
Related calculators
Related guides
MathPercentages people get wrong: change, difference and pointsThe denominator determines the answer. Learn to distinguish percentage change, symmetric difference and percentage-point movements.14 November 2026 · 7 min read
MathStandard deviation without the jargonThe average tells you the centre. Standard deviation helps describe the spread, provided you know what the data represents.14 November 2026 · 7 min readSources and standards
About the author
Dr. Hassan Khames Eliwa holds a PhD in Construction & Built Environment and has more than 20 years of international project controls experience. He is Director of Eliwa Project Controls Limited in Auckland and founder of PMMilestone.org and PMMilestone.com.
Buy me a coffee