Random Number Generator
A random number generator gives you a fast, unbiased way to pick one or more whole numbers from a range you choose. Enter a minimum value, a maximum value, how many numbers you want, and decide if repeats are allowed. The tool then returns an instant result that fits inside those limits.
Quick answer
This random number generator works with whole numbers, so both the minimum and maximum values are included as possible outcomes.
What this tells you
- •This random number generator works with whole numbers, so both the minimum and maximum values are included as possible outcomes.
- •If you generate one number from 1 to 10, every integer from 1 through 10 has the same chance on that single draw.
- •If Allow duplicates stays checked, the same number can appear more than once in a multi-number result or across repeated runs.
- •If Allow duplicates is turned off, the tool keeps picking until it has the requested count of unique numbers.
- •If you enter the larger number first and the smaller number second, the calculation logic still uses the lower value as the true minimum and the higher value as the true maximum.
- •The tool also calculates the count, sum, and average of the generated numbers, which helps when you use random values for testing or classroom exercises.
- •This page uses pseudo-random browser logic, which is appropriate for everyday selection tasks but not for security, encryption, or high-stakes gambling systems.
How to Use
- 1Enter the minimum number you want the tool to allow. This can be positive, negative, or zero.
- 2Enter the maximum number. The tool treats both endpoints as valid possible results, so a range of 1 to 6 behaves like a standard six-sided die.
- 3Choose how many numbers to generate in the Amount to generate field. Use 1 for a single pick, or a larger number if you want a short list.
- 4Decide if repeats should be allowed. Leave the box checked for rolls, simulations, or loose sampling. Uncheck it for unique draws such as raffle tickets, draft order, or seat assignment.
- 5Click the button to generate your result, then review the generated numbers along with the count, sum, and average. Run it again any time you want a fresh draw.
How It Works
Formula
R = Math.floor(Math.random() * (max - min + 1)) + minThe core formula starts by finding the size of the inclusive range with max - min + 1. That range size is multiplied by Math.random(), which produces a decimal from 0 up to but not including 1. Math.floor then drops the decimal portion so the temporary value becomes a whole-number offset starting at 0. Adding min shifts that offset into your chosen range. For example, if min = 10 and max = 15, the range size is 6, the temporary whole-number offset can be 0 through 5, and the final result can be 10 through 15. When you request more than one number, the tool repeats that process for each draw. If duplicates are not allowed, it stores picks in a Set until it reaches the requested amount. It also checks that the number of unique values requested does not exceed the number of values available in the range.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
Pick one student number from 1 to 30
The inclusive range contains 30 possible values because 30 - 1 + 1 = 30. A result of 17 is valid because the formula can return any whole number from 1 through 30. Since only one number was requested, the main result displays that single value by itself.
Generate five dice-style results
This setup acts like rolling a six-sided die five times because the allowed values are 1 through 6 and repeats are allowed. The sample output sums to 19 because 4 + 2 + 6 + 2 + 5 = 19. The average is 3.8 because 19 ÷ 5 = 3.8, which matches how the tool calculates the secondary results.
Draw three unique raffle tickets
The range includes 11 possible ticket numbers because 110 - 100 + 1 = 11. Requesting 3 unique picks is valid because 3 is less than or equal to 11. In this sample draw, all three values are different, the sum is 314, and the average is 104.67 because 314 ÷ 3 = 104.666..., which the tool rounds to two decimal places.
Use a negative-to-positive test range
This range contains 7 possible integers: -3, -2, -1, 0, 1, 2, and 3. The sample output is valid because every listed value falls inside that inclusive range, and duplicates are allowed. The sum is 4 because 0 + (-2) + 3 + 3 = 4, and the average is 1 because 4 ÷ 4 = 1.
Enter the larger bound first
The calculation logic swaps the order internally by using the smaller input as the true minimum and the larger input as the true maximum. That means this setup behaves like a range from 10 to 50, not an invalid request. A result of 22 is therefore a valid outcome inside the corrected range.
Ask for too many unique values
This request fails because the range only contains 5 unique integers: 1, 2, 3, 4, and 5. With duplicates turned off, the tool cannot produce 7 different results from only 5 available values. In that case, the formula returns an error state with the message Range too small.
Common random-number range ideas
Simple range patterns that match everyday uses for a random number generator.
| Use case | Typical minimum | Typical maximum | Duplicate setting |
|---|---|---|---|
| Coin flip style binary choice | 0 | 1 | Allowed |
| Six-sided die roll | 1 | 6 | Allowed |
| Pick a classroom seat | 1 | 30 | Usually allowed |
| Raffle ticket draw | 1 | 500 | Not allowed |
| Draft order for 10 teams | 1 | 10 | Not allowed |
| Quick test data sample | -10 | 10 | Allowed |
The best range depends on the number of distinct outcomes you need. If each number should appear only once, make sure the range contains at least as many values as the amount requested.
When should you allow duplicates?
Allow duplicates when each draw should be independent from the last one. Dice rolls, coin-flip style picks, random test data, and repeated game events all fit that pattern. In those cases, seeing the same value twice is normal, not a mistake.
Turn duplicates off when each number represents a slot that can only be used once. Raffle winners, tournament seeds, presentation order, classroom turn-taking, and unique coupon assignment all need distinct picks. If the same number showed up twice in those situations, you would have to redraw anyway.
The size of the range matters most when duplicates are off. Asking for 20 unique numbers from a range of 1 to 10 cannot work because only 10 different integers exist in that span. The built-in range check stops that request before the tool tries to create an impossible result.
For repeated decisions, think about fairness and readability together. A tight range like 1 to 3 is fine for a quick game prompt, but a wider range like 1 to 100 gives more spread when you want results to feel less clustered. Matching the range to the real task prevents confusion after the number appears.
Common mistakes
- Assuming the maximum value is excluded. This tool uses an inclusive range, so both the minimum and maximum numbers can appear.
- Turning duplicates off without checking the range size first. If you need 20 unique numbers, the range must contain at least 20 different integers.
- Reading short runs as proof of bias. Random output often creates streaks or repeats in small samples, even when the selection method is working normally.
- Using a basic random number generator for passwords, access codes, or other security-sensitive tasks. This tool is built for ordinary selection and testing, not cryptographic protection.
- Ignoring the sum and average fields when you generate many values for practice sets or test data. Those extra outputs are useful for quick sanity checks.
Embed this calculator on your site
Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.
<script src="https://calctide.com/embed.js" data-tool="random-number-generator" async></script>Preview the embed at /embed/random-number-generator/.