Random Number Generators, Explained

By Udit Agarwal · Updated October 17, 2026

A random number generator (RNG) produces numbers that cannot be predicted, with every value in its range equally likely. To pick a random number between 1 and 100, set the minimum to 1 and the maximum to 100: a good generator gives each of the 100 numbers a 1 percent chance on every draw. Computers make these numbers either with fast pseudo-random formulas or with cryptographically secure generators, and the difference matters for anything from a raffle to a password.

Pseudo-random vs cryptographically secure

A pseudo-random number generator (PRNG) is a formula. It starts from a value called the seed and produces a sequence that looks random, yet the same seed always gives the same sequence. That helps when you want to repeat a simulation or an auditable draw, and hurts when numbers must stay secret, since anyone who learns the internal state can predict the rest.

Seeded PRNG Math.random() crypto.getRandomValues()
Can outputs be predicted? Yes, by anyone with the seed In principle, from enough outputs Not in practice
Good for Repeatable simulations, auditable draws Games and visual effects Passwords, tokens, prize draws

The JavaScript standard, ECMA-262, only asks Math.random for an approximately uniform number from 0 up to, but not including, 1, and leaves the algorithm to each browser; MDN warns against using it for anything security-related. The Web Cryptography API specification asks browsers to build crypto.getRandomValues on a well-established cryptographic generator seeded with high-quality entropy, such as the operating system's.

ArrayKit's Random Number Generator uses crypto.getRandomValues, taking one 32-bit random value for each number it draws. It falls back to Math.random only in a browser with no Web Crypto support, and every current browser has it. For draws that others must be able to rerun and check, the seeded Random Name Picker fits better.

How to pick a random number between 1 and 100

Most online generators, ArrayKit's included, treat the range as inclusive: both the minimum and the maximum can come up. The number of possible values is therefore max − min + 1.

Range Possible values Chance of each
1 to 100 100 1%
0 to 100 101 about 0.99%

Off-by-one mistakes are a common bug in hand-written code. Given a random number r from 0 up to 1, the standard formula for a whole number from min to max is:

Math.floor(r * (max - min + 1)) + min

Leave out the + 1 and the maximum never appears. Write Math.round(r * (max - min)) + min instead and the two end values come up half as often as the others.

In the Random Number Generator, Min and Max can be any numbers, including negatives, and if they are equal every draw returns that number. Set Decimals above 0 for results such as 7.42. With decimals, the tool picks a whole number of steps and divides, so every value at that precision is equally likely, the two ends included: from 0 to 1 at one decimal place, each of the 11 values comes up about 9 percent of the time.

What is modulo bias?

Modulo bias appears when a random source with a fixed number of outcomes is squeezed into a range that does not divide it evenly. The classic case turns a random byte, one of 256 values, into a die roll with byte % 6 + 1. Because 256 = 6 × 42 + 4, faces 1 to 4 collect 43 byte values each (16.80 percent) and faces 5 and 6 only 42 (16.41 percent).

The standard fix is rejection sampling: discard the leftover values, here bytes 252 to 255, and draw again, which costs a redraw about 1.6 percent of the time and makes every face exactly equal. The other remedy is to start from far more random bits than the range needs, so the leftover becomes tiny.

ArrayKit's Random Number Generator takes the second route, scaling one 32-bit value onto your range with no rejection step. For 1 to 100, 96 numbers are backed by 42,949,673 of the 4,294,967,296 possible values and the other 4 by 42,949,672: a difference of about one part in 43 million, far too small to show up in any realistic number of draws. The gap grows with the range and can pass 1 percent above about 43 million possible numbers, and in a range of more than 4,294,967,296 numbers some can never be drawn. For secrets, use a tool built for them: the Password Generator picks every character with rejection sampling.

Random numbers without repeats

Turn on Unique values and no number appears twice in one batch. This is sampling without replacement, like balls leaving a lottery drum. The tool keeps drawing, discarding numbers it already has, until it reaches your count, which gives every set of numbers the same chance.

The one hard limit is arithmetic: you cannot draw more distinct numbers than the range contains. From 1 to 10 there are ten whole numbers, so asking for 11 unique values stops with the message "The range only holds 10 unique values at 0 decimal places" and suggests lowering the count, widening the range or adding decimals. One decimal place gives 1 to 10 room for 91 values. Asking for every number in the range returns each one once in random order, so 1 to 30 with a count of 30 sets a presentation order for a class of 30.

Without the switch, repeats arrive sooner than most people expect. This is the birthday problem. Draw 10 numbers from 1 to 100 and the chance of at least one repeat is 37.2 percent; at 13 numbers it is 55.7 percent, and at 20 numbers 87.0 percent.

Sorted, or in the order drawn?

The Random Number Generator lists numbers in the order they were drawn, which matters when the sequence is the result, such as who presents first. For lottery numbers only the set counts, so sorting changes nothing about the odds and makes the list easier to read. The tool has no sort button: copy the comma-separated result, split it into lines with the Delimiter Converter and sort it with Sort Text Lines in Numeric mode, which orders positive whole numbers correctly.

Lottery-style draws and their real odds

A lottery ticket is a set of unique numbers where order does not count, so the number of possible tickets is the combination count C(n, k) = n! / (k! × (n − k)!). To fill a 6-from-49 ticket, set Min 1, Max 49, Count 6 and turn on Unique values. The chance of matching all six is 1 in C(49, 6) = (49 × 48 × 47 × 46 × 45 × 44) / 6! = 13,983,816.

A bonus ball from a separate pool multiplies the two counts, and in the generator it is a second draw with its own range:

Draw format Jackpot odds per ticket
6 from 49 1 in 13,983,816
5 from 69 plus 1 from 26 (US Powerball) 1 in 292,201,338
5 from 50 plus 2 from 12 (EuroMillions) 1 in 139,838,160

Smaller prizes are far more likely. In a 6-from-49 game, matching exactly three numbers happens about once in 57 tickets, because C(6, 3) × C(43, 3) = 20 × 12,341 = 246,820 of the 13,983,816 combinations do it. Every combination is equally likely, including 1, 2, 3, 4, 5, 6, and no way of choosing numbers changes the odds; choice only affects how many people might share a jackpot, since many players crowd the birthday numbers 1 to 31. The Permutation and Combination Calculator works out C(n, k) for any other format.

Dice, coins and other everyday draws

For one die, draw from 1 to 6; for a d20, 1 to 20; for percentile dice, 1 to 100. For several dice, set the count to the number of dice and leave Unique values off, since real dice can show the same face. For a coin, draw from 1 to 2 and decide beforehand which number is heads. For a raffle with tickets numbered 1 to 500, draw 3 unique numbers for three prizes.

One trap: the total of two dice is not a random number from 2 to 12. A 7 can be made 6 ways out of 36 (16.7 percent), while 2 and 12 have one way each (2.8 percent). A single draw from 2 to 12 would make every total 9.1 percent likely, so draw the dice separately and add them. The Dice Roller does that for up to 100 dice with a modifier, and Coin Flip tosses up to 100 coins and rates how unusual a streak is. For picking names rather than numbers, see how a spin-the-wheel picker works.

Generate numbers with ArrayKit

The Random Number Generator has four fields, Min, Max, Count and Decimals (1, 100, 5 and 0 by default), and a Unique values switch. Press Generate and the numbers appear in the order drawn, with a button that copies them as a comma-separated list. Error messages explain what to fix, such as Max below Min or a range too small for the unique count.

Its limits: one range per batch, so a bonus ball needs a second draw; no sorting; and no seed, so keep a copy of any batch you need as a record. Numbers are generated in your browser, and nothing is uploaded.

Frequently asked questions

Is an online random number generator really random? A good one is unpredictable for every practical purpose. ArrayKit's generator draws from crypto.getRandomValues, the browser's cryptographic source, which is designed so that earlier numbers reveal nothing about the next.

How do I pick a random number between 1 and 100? Set Min to 1, Max to 100 and Count to 1, then generate. Both ends are included, so there are 100 possible numbers and each has a 1 percent chance.

How do I get random numbers without repeats? Turn on Unique values. The count cannot exceed the number of values in the range, so 1 to 10 gives at most ten unique whole numbers.

What is a seed in a random number generator? It is the starting value of a pseudo-random formula: the same seed always produces the same sequence, so a draw can be repeated and checked. ArrayKit's Random Number Generator uses a cryptographic source instead, so it has no seed.

Can I use a random number generator to make a password? Use a password generator instead, since it picks characters rather than numbers. ArrayKit's Password Generator draws from the same cryptographic source and uses rejection sampling for every pick.

What are the odds of winning a 6-from-49 lottery? One in 13,983,816 per ticket for the jackpot, the number of ways to choose 6 numbers from 49. Matching exactly three numbers is about 1 in 57.

Keep going

Random Number Generator

More guides

  • How to Add, Subtract, Multiply and Divide Fractions — How to add fractions with a common denominator, subtract, multiply, divide and simplify them, and convert mixed numbers and decimals, with worked examples.
  • How to Calculate Standard Deviation — How to calculate standard deviation step by step, with a worked example, variance, sample vs population (n − 1 or n), the 68–95–99.7 rule and STDEV.S.
  • How to Calculate Percentages — How to calculate percentage problems: X% of Y, what percent one number is of another, the percentage increase formula, reverse percentages and common mistakes.
  • Base64 Encoding, Explained — Base64 explained: how it turns binary into text, the alphabet and padding, the URL-safe variant, size overhead, use cases, and why it isn't encryption.
  • Linux File Permissions and chmod, Explained — What chmod 755, 644 and 777 mean: owner, group and others, read, write and execute, octal and symbolic modes, umask, setuid, setgid and the sticky bit.
  • DMS and Decimal Degrees, Explained — How to convert DMS to decimal degrees and back, how DD, DMS and DDM differ, how many decimal places you need, and which formats Google Maps and GPS accept.

All Math tools · All guides