The direct answer: to generate a random number from 1 to 20, use a random number generator tool, a spreadsheet formula like =RANDBETWEEN(1,20) in Excel, or a programming function such as random.randint(1,20) in Python. Each method gives a whole number between 1 and 20 inclusive, with each value equally likely if the generator is truly random.
What Does “Random” Actually Mean?
When people ask for a random number 1-20, they usually want a uniform distribution—meaning every integer from 1 to 20 has the same chance of being selected. True randomness is hard to achieve with computers because they follow deterministic algorithms. These algorithms, called pseudo-random number generators (PRNGs), use a seed value and a mathematical formula to produce a sequence that appears random but is actually reproducible if you know the seed.
For most everyday uses—picking a contest winner, choosing a number for a game, or making a decision—a pseudo-random generator is perfectly fine. Cryptographic applications, however, require stronger randomness from sources like hardware entropy or atmospheric noise, which are not predictable.
Ways to Generate a Random Number 1-20
Here are the most common methods, from simple to technical:
- Online generators: Websites like random.org use atmospheric noise to produce true randomness. You can set the range to 1-20 and get a number instantly.
- Physical methods: Roll a 20-sided die (d20), often used in tabletop games. Write numbers 1-20 on slips of paper, fold them, and draw one from a hat.
- Spreadsheets: In Excel or Google Sheets, the formula
=RANDBETWEEN(1,20)returns a random integer in that range. In Excel, you can also use=INT(RAND()*20)+1. - Programming languages: In Python,
import random; random.randint(1,20)does the job. In JavaScript,Math.floor(Math.random()*20)+1works. - Calculator or phone: Many scientific calculators have a random integer function; smartphone apps and voice assistants can also generate random numbers.
How to Use a Random Number Generator
Using an online tool is straightforward: enter the minimum (1) and maximum (20), then click generate. If you’re using a spreadsheet, type the formula into any cell and press Enter. The cell will display a number like 14. Press F9 (Windows) or Cmd+Enter (Mac) to recalculate and get a new number. In Python, run the code in a script or interactive shell. For a physical die, simply roll it and read the top face.
If you need multiple random numbers, you can generate a list. In Excel, copy the formula down a column to get several numbers. For a single number, the process is the same.
Common Problems and Misconceptions
One frequent issue is that people think a random number generator is “broken” if it repeats the same number twice in a row. That’s not a flaw—true randomness allows repeats. For example, rolling a d20 twice could give 7 both times; the probability is 1/400, which is small but possible.
Another misconception: using the current time as a seed in programming (like Math.random()) makes it “more random.” Actually, it just changes the starting point; the sequence is still deterministic. For most purposes, this is fine, but for security-sensitive applications, use a cryptographically secure generator.
Also, be careful with formulas like =RAND()*20 in Excel—this returns a decimal between 0 and 20, not an integer. You need to round or use RANDBETWEEN to get whole numbers.
How to Choose the Right Method
Consider your context:
- Fairness: If you need an unbiased result (e.g., drawing a winner), use a true random source like random.org or a physical die. Pseudo-random is fine for games.
- Convenience: For quick decisions, a phone app or voice assistant is fastest.
- Reproducibility: If you need to recreate the same sequence (e.g., for testing), use a seeded PRNG in programming. In Excel, you can set a seed with
=RANDBETWEENonly if you use the Analysis ToolPak, but it’s easier to use a fixed seed in Python. - Volume: For generating hundreds of numbers, a spreadsheet or script is more efficient than rolling dice.
Cost and Safety Considerations
Most random number generators are free. Online tools like random.org offer free basic use; some have premium features for bulk generation. Spreadsheet functions are included in Excel and Google Sheets. Programming languages have built-in libraries at no cost.
Safety is rarely an issue, but be cautious when using random numbers for security purposes—like generating passwords or encryption keys. Use a cryptographically secure generator (e.g., Python’s secrets module) and never rely on Math.random() for such tasks. Also, avoid using random numbers for gambling or financial decisions; those require regulated systems.
Alternatives to Random Number Generators
If you don’t have a generator handy, you can use:
- Dice: A standard six-sided die can be rolled twice: first roll determines the tens digit (0-1) and second roll the ones digit (1-6), but that’s clunky. Better to use a d20.
- Playing cards: Assign numbers to cards (e.g., Ace=1, 2-10, Jack=11, Queen=12, King=13) but you’d need two suits to reach 20.
- Clock seconds: Look at the last digit of the current second and combine with another digit, but this is biased.
- Human choice: Ask a friend to pick a number—but humans are notoriously bad at being random; they tend to avoid extremes.
For most needs, a simple online generator or spreadsheet formula is the best balance of speed and fairness.
Frequently Asked Questions
Can I get a random number 1-20 without a computer?
Yes. Roll a 20-sided die, draw from a shuffled deck of 20 cards, or use a random number table from a book. These are all physical methods that give uniform results if done properly.
Why does Excel’s RANDBETWEEN sometimes repeat numbers?
Because it’s random. Each time you recalculate, the formula produces a new independent number. Repeats are expected and don’t indicate a problem.
Is RAND() in Excel truly random?
No, it’s pseudo-random. Excel uses an algorithm that generates a sequence based on a seed. It’s good enough for most purposes, but not for cryptography.
How do I generate a random number 1-20 in Google Sheets?
Use the same formula: =RANDBETWEEN(1,20). Google Sheets recalculates on change, and you can force a refresh by pressing Ctrl+R (Windows) or Cmd+R (Mac).
What’s the difference between RAND() and RANDBETWEEN()?
RAND() returns a decimal between 0 and 1 (e.g., 0.456), while RANDBETWEEN() returns an integer within a specified range. For a whole number 1-20, use RANDBETWEEN.
Can I use a random number generator for a lottery?
Yes, but if it’s for a real lottery, the generator must be certified and truly random. For casual use, it’s fine, but remember that each number has an equal chance—no strategy can improve your odds.
Related
- Formatting a Cell in Excel: The Complete Guide
- Java String split() Method: How to Use It
- Shortcut to Shut Down PC: Fastest Ways
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Combine Cells in Excel and Add a SpaceTo combine text from two Excel cells with a space between it, enter a formula in an empty…
- Delete Blank Rows in Excel: Safe Step-by-Step GuideTo delete completely blank rows in Excel safely, add a temporary helper column with =COUNTA(A2:F2)=0, filter that column…
- Traffic Light Changer Device: How It Works & Legal RisksA traffic light changer device is an illegal aftermarket gadget that transmits an infrared or radio signal to…
- How to Open Excel in a Browser and Edit Your FilesTo open Excel in a browser, go to microsoft365.com, sign in with a Microsoft account, and select Excel.…
- Excel Yellow Color Code: RGB, Hex, and Theme ValuesExcel’s standard pure-yellow fill is RGB 255, 255, 0, written in hexadecimal as #FFFF00. Choose the yellow square…
- How to Set Up Auto Forwarding in OutlookTo automatically forward incoming Outlook email, open Settings, go to Mail > Forwarding, enable forwarding, enter the destination…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.