Skip to content
CalcTide logo
Writing & Utility

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.

Writing & UtilityBy

Quick answer

This random number generator works with whole numbers, so both the minimum and maximum values are included as possible outcomes.

The lowest possible value.

The highest possible value.

How many numbers to generate (max 1000).

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

  1. 1Enter the minimum number you want the tool to allow. This can be positive, negative, or zero.
  2. 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.
  3. 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.
  4. 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.
  5. 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)) + min

The 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

Minimum1
Maximum30
Amount1
Allow duplicatesYes
Result17

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

Minimum1
Maximum6
Amount5
Allow duplicatesYes
Result4, 2, 6, 2, 5

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

Minimum100
Maximum110
Amount3
Allow duplicatesNo
Result104, 109, 101

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

Minimum-3
Maximum3
Amount4
Allow duplicatesYes
Result0, -2, 3, 3

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

Minimum50
Maximum10
Amount1
Allow duplicatesYes
Result22

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

Minimum1
Maximum5
Amount7
Allow duplicatesNo
ResultError

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 caseTypical minimumTypical maximumDuplicate setting
Coin flip style binary choice01Allowed
Six-sided die roll16Allowed
Pick a classroom seat130Usually allowed
Raffle ticket draw1500Not allowed
Draft order for 10 teams110Not allowed
Quick test data sample-1010Allowed

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/.

Frequently Asked Questions

It chooses a value by creating a pseudo-random offset inside your inclusive range, then shifting that offset by the minimum value. In plain terms, the tool converts your min and max settings into a pool of allowed whole numbers and picks from that pool.
Yes. Enter a larger value in Amount to generate and the tool will return a list instead of a single number. It also calculates the total count, sum, and average for that batch.
The tool will keep drawing until it has the requested number of unique values. If you ask for more unique numbers than the range contains, it stops and returns an error instead of repeating a value.
Yes. The calculation logic reorders the two inputs internally so the smaller number acts as the minimum and the larger number acts as the maximum. That helps the tool stay usable even if the values are entered in reverse.
Yes. Negative integers work as long as they fit the range you enter. A span like -5 to 5 is valid and can return negative values, zero, or positive values.
That can happen because each new run starts a fresh random draw. If duplicates are allowed, the same number can appear again immediately, especially in smaller ranges like 1 to 10.
No, not in the strict mathematical sense used for physical randomness or cryptography. It uses pseudo-random browser behavior, which is suitable for raffles in class, games, quick picks, and software testing where simple randomization is enough.
No. Passwords, security tokens, and similar secrets should come from a security-focused generator designed for cryptographic use. This tool is meant for everyday random-number tasks, not secure credential creation.
It estimates random number generator outputs using the visible inputs and formula assumptions on this page.

Explore More in Writing & Utility