Random Number Generator 1-100: How It Works

How-to basics · Updated November 23, 2026

Yes, a random number generator (RNG) for 1–100 produces a whole number between 1 and 100, with each number having an equal chance of being selected. This is called a uniform distribution, and it is the standard for most online pickers, spreadsheet functions, and programming languages.

What Does “Random” Really Mean Here?

When you ask for a random number from 1 to 100, you want each integer (1, 2, 3, … 100) to appear with the same probability: 1 in 100, or 1%. That is the mathematical ideal. In practice, the method used to generate the number determines whether that ideal is met. For casual uses like picking a lottery-style number or choosing a contest winner, any decent RNG is more than sufficient. For cryptography or scientific simulations, the standard is much stricter, and you would use a cryptographically secure generator (see below).

How Online Random Number Generators Work

Most websites and apps use a pseudo-random number generator (PRNG). A PRNG starts with a seed—a number that initializes the algorithm. The seed can come from the current time in milliseconds, mouse movements, or other unpredictable system events. Then, a mathematical formula (like the Mersenne Twister or xorshift) produces a long sequence of numbers that appear random. The sequence is deterministic: if you use the same seed, you get the same sequence. That is fine for most purposes, but it means the output is not truly random in the philosophical sense.

For a 1–100 range, the generator typically produces a floating-point number between 0 and 1, multiplies it by 100, and rounds up or down to get an integer. For example, if the random float is 0.731, then 0.731 × 100 = 73.1, which rounds to 73. The exact rounding method varies, but the result is a uniform integer.

Using Spreadsheets: Excel and Google Sheets

If you need a random number in a spreadsheet, you have built-in functions.

  • Excel (Microsoft 365): Use =RANDBETWEEN(1,100) to get an integer between 1 and 100 inclusive. The function recalculates every time the sheet changes. For a set of random numbers, fill down the formula. To keep the numbers fixed, copy the cells and paste as values (right-click > Paste Special > Values).
  • Google Sheets: The same function =RANDBETWEEN(1,100) works, but it recalculates only when the sheet is edited or the function is refreshed. To generate a random decimal between 1 and 100 (not integer), use =RAND()*99+1 in either program. That returns a number like 45.732, not a whole number.

Note: In Excel on Mac, the function and syntax are identical. In Excel for the web, RANDBETWEEN works the same way.

How to Choose a Good Generator

For everyday tasks, almost any generator works. But here are factors to consider:

  • Purpose: For a classroom activity or picking a random winner, a simple online picker is fine. For a scientific study or a game where fairness matters, use a generator with a known algorithm and a way to verify randomness.
  • Security: If you are generating passwords, tokens, or anything security-sensitive, never use a standard PRNG. Use a cryptographically secure random number generator (CSPRNG). In programming, that means functions like crypto.getRandomValues() in JavaScript or secrets module in Python. These use entropy from the operating system, not just a seed.
  • Bias: Some naive implementations (like using rand() % 100 in C) can introduce a slight bias because the range of the underlying PRNG may not be a multiple of 100. Modern languages and libraries handle this correctly, but if you are coding your own, be aware.

Common Problems and Misconceptions

One common misconception is that a random sequence should not have repeats or patterns. In a true random sequence of 100 numbers, you might see the same number twice in a row—that is normal. Another issue is the gambler’s fallacy: if you roll a 50, the next roll is not less likely to be 50. Each roll is independent.

A frequent problem with online generators is that they may not be truly random if they rely on a weak seed. Some older generators used the system clock in seconds, making it possible to predict the next number. Modern browsers and operating systems use much better sources.

Also, be careful with rounding: if you want numbers from 1 to 100 inclusive, ensure the generator does not produce 0 or 101. A common bug is using Math.floor(Math.random() * 100) which gives 0–99, not 1–100. The correct formula is Math.floor(Math.random() * 100) + 1.

Physical Alternatives: Dice and Randomness

If you do not trust software, you can use physical methods. For 1–100, you can roll two ten-sided dice (0–9 each). Designate one die as the tens digit and the other as the ones digit. A roll of 0 on both gives 100 (or 0, depending on convention). Alternatively, use a hundred-sided die (a Zocchihedron), but it is rare and not perfectly uniform. Or draw numbered slips from a hat—if you shuffle well.

Physical methods are truly random if the process is fair, but they are slower and can have human bias in shuffling.

Costs and Safety

Most online random number generators are free. There is no cost to using a website or a spreadsheet function. For programming, the built-in libraries are free as well. The only cost might be if you need a hardware random number generator (like a device that measures radioactive decay or atmospheric noise) for high-stakes applications—these are rare and expensive.

Safety is not a concern for generating numbers, but be cautious about websites that ask for personal information. A simple random number picker should not require any sign-up. Also, if you use a random generator for something like a giveaway, ensure the method is transparent and documented to avoid disputes.

Frequently Asked Questions

Can I get the same number twice in a row?
Yes, absolutely. In a uniform distribution, each number is independent. The chance of getting the same number twice in a row is 1 in 100, just like any other pair. It may feel non-random, but it is not a flaw.

How do I generate a random number in Python?
Use the random module: import random then random.randint(1, 100). For security, use secrets.randbelow(100) + 1.

Is the RNG in my browser truly random?
No, it is pseudo-random, but modern browsers use a secure seed source (like OS entropy) so it is good enough for most purposes. For cryptographic use, the crypto.getRandomValues() API is available.

Why do some generators give 0 sometimes?
That happens when the formula is off by one. If you see 0, the generator is probably using a range of 0–99 instead of 1–100. Always check the documentation.

Can I use a random number generator for a lottery?
Yes, but it will not improve your odds. The lottery is designed so each combination is equally likely, and a random picker just gives you a random combination. It is no better or worse than picking your own numbers.

How do I generate a random number without a computer?
Use dice, a spinner, or a deck of cards. For 1–100, you can use two ten-sided dice as described above. Or, write numbers 1–100 on slips of paper, put them in a bowl, and draw one after shaking well.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.