How it works
The method behind the number.
Generate a random whole number within a range. This tool explains the calculation so you can adjust the assumptions to match your situation.

Everyday math
Generate a random whole number within a range.
Enter your numbers to see the answer.
Random number generator guide
This generator returns one whole number between the minimum and maximum you set, with both ends included, so the default range of 1 to 100 has exactly 100 possible outcomes and each is equally likely. It is useful for picking a raffle winner from numbered tickets, choosing who goes first, selecting a sample row from a spreadsheet, rolling a die (1 to 6), or simulating a coin (1 to 2). If you enter the limits in the wrong order the tool swaps them, and decimal limits are floored to whole numbers. Be clear about what it is not: the number comes from the browser’s Math.random(), a fast pseudorandom generator that is fine for games, choices, and classroom demonstrations but is not a cryptographically secure random number generator (CSPRNG). Passwords, tokens, lottery draws with money at stake, and anything an adversary might try to predict should use a CSPRNG such as the Web Crypto API instead. Each click draws a fresh number; previous results are not remembered or excluded.
Result = floor(random × (max − min + 1)) + min, where random is a uniform value in [0, 1). The number of possible outcomes is max − min + 1.
Worked example with the defaults: minimum 1, maximum 100. The span is 100 − 1 + 1 = 100 possible values. The generator picks a uniform decimal in [0, 1), multiplies by 100 to land in [0, 100), floors it to a whole number from 0 to 99, and adds the minimum: 0 → 1 and 99 → 100. Every integer from 1 to 100 therefore has a 1 ÷ 100 = 1% chance. One click might show 37; the next is independent, so 37 can appear again immediately with the same 1% probability.
Minimum and maximum are unitless integers; decimals are truncated toward negative infinity before use, so 1.7 behaves as 1. Negative limits are fine, so −10 to 10 gives 21 outcomes. There is no unit on the result. For dice, enter 1 and 6; for a coin, 1 and 2; for a percentage, 0 and 100.
The result follows directly from the numbers you entered, so its accuracy is the accuracy of those inputs. The most common source of a surprising answer is a mismatch between the question you meant to ask and the one the calculator answered, so re-read the field labels if the figure looks wrong. The formula is shown above so you can check the arithmetic yourself. On this page the figure rests entirely on minimum and maximum, so start there if the random number generator returns something you did not expect.
Good to know: “between 1 and 100” here includes both 1 and 100, unlike some generators that exclude the upper limit, so count outcomes as max − min + 1. Runs of repeats are normal in genuine randomness and are not a fault. Do not use this page to generate passwords, PINs, or security codes; Math.random() is predictable in principle. If you need several numbers with no repeats, draw one at a time and re-roll duplicates, because the tool does not track history.
Results are planning estimates. Check the units, product coverage, carrier rules, or local rates before making a purchase or financial decision.
Sources
How it works
Generate a random whole number within a range. This tool explains the calculation so you can adjust the assumptions to match your situation.
Worked example
With Minimum = 1 · Maximum = 100 → 45 (random whole number). Change an input above and this example updates with your numbers.
Common questions
100, because both endpoints count: 100 − 1 + 1 = 100. Each has a 1% chance on every draw. A range of 1 to 6 has 6 outcomes, like a standard die, each with a 16.67% chance.
No. It uses the browser’s Math.random(), a pseudorandom algorithm seeded by the browser. The output is statistically uniform and unpredictable enough for games and picks, but it is not certified for cryptography or regulated gaming.
A cryptographically secure pseudorandom number generator produces output that cannot be predicted even by someone who has seen earlier values, meeting standards such as NIST SP 800-90A. Use one, for example crypto.getRandomValues, for passwords, keys, and tokens.
Each draw is independent, so a repeat has the same probability as any other value: 1 in 100 for the default range. Over 100 draws, seeing at least one immediate repeat is more likely than not (about 63%).
Set the minimum to 1 and the maximum to the number of tickets sold, then generate once. For a prize draw with legal or financial stakes, use a method your jurisdiction accepts, which may require a CSPRNG or a witnessed physical draw.
Not with this tool, which returns whole numbers only. For a random decimal between 0 and 1 to two places, generate an integer from 0 to 100 and divide by 100.