Random Number Generator
Generate random integers, even numbers, or odd numbers within any range. Supports up to 1,000 numbers with sorting, copy, and history. See also Percentage Calculator and Combinations Calculator.
Range: 100 possible values
How to Generate Random Numbers
Set your minimum and maximum values to define the range, choose how many numbers to generate (up to 1,000), and select your options. You can generate all integers, only even numbers, or only odd numbers. Enable "Unique only" to prevent duplicates, and choose a sort order if needed. Use the quick preset buttons for common scenarios like dice rolls, coin flips, lottery picks, or PIN codes. Click Generate to produce your random numbers instantly. Every generation is saved in the history panel so you can reference previous results.
Random Number Formula
Random integer in [min, max]:
result = floor(random() × (max − min + 1)) + min
For unique numbers: Fisher-Yates shuffle on pool, take first N
For even only: filter pool where n % 2 === 0
For odd only: filter pool where n % 2 !== 0
Common Use Cases
Lottery Numbers
Generate 6 unique numbers from 1-49 for lottery quick picks
Dice Simulation
Roll one or multiple dice (1-6) for board games
PIN Codes
Generate random 4-digit PIN codes (0-9, 4 numbers)
Raffle Drawing
Pick random winners from numbered tickets
Statistical Sampling
Generate random sample indices for research
Password Seeds
Create random number sequences for password generation
Example
Generate 6 unique numbers between 1 and 49 (lottery)
Range: 1 to 49 (49 possible values)
Count: 6, Unique: Yes, Sort: Ascending
Possible result: 3, 12, 23, 31, 38, 47
Frequently Asked Questions
Are these truly random numbers?
This generator uses pseudorandom numbers from your browser's Math.random() function, which is suitable for games, simulations, raffles, and general use. For cryptographic purposes (passwords, encryption keys), use a cryptographically secure random number generator (CSPRNG).
Can I generate negative numbers?
Yes. Set the minimum to a negative value. For example, min = -50 and max = 50 will generate numbers in that range, including negative values and zero.
What is the Fisher-Yates shuffle?
The Fisher-Yates (Knuth) shuffle is an algorithm that produces an unbiased random permutation of a sequence. It iterates through the array and swaps each element with a randomly chosen element from the remaining unshuffled portion. This ensures every permutation is equally likely.
How many numbers can I generate at once?
You can generate up to 1,000 numbers at once. For unique numbers, the count cannot exceed the number of available values in your range (after filtering for even/odd if selected).
What is the difference between even and odd number generation?
When you select "Even," only numbers divisible by 2 are included in the pool (e.g., 2, 4, 6...). When you select "Odd," only numbers not divisible by 2 are included (e.g., 1, 3, 5...). "All" includes every integer in the range.
Solved Examples — Random Number Generation
Example: What is the probability of generating the number 7 from a uniform random selection between 1 and 20?
Solution:
Step 1: Total possible outcomes = 20 − 1 + 1 = 20
Step 2: Favorable outcomes = 1 (only the number 7)
Step 3: Probability = 1/20 = 0.05 = 5%
Answer: 5% (or 1 in 20)
Example: How many unique combinations exist when picking 6 numbers from 1–49 (lottery)?
Solution:
Step 1: Use combinations formula: C(49,6) = 49! / (6! × 43!)
Step 2: = (49 × 48 × 47 × 46 × 45 × 44) / (6 × 5 × 4 × 3 × 2 × 1)
Step 3: = 10,068,347,520 / 720 = 13,983,816
Answer: 13,983,816 possible combinations
Example: If you generate 5 random even numbers from 2 to 30, how many possible values are in the pool?
Solution:
Step 1: Even numbers from 2 to 30: 2, 4, 6, ..., 30
Step 2: Count = (30 − 2)/2 + 1 = 15 even numbers
Step 3: With 15 values in the pool, unique selections of 5 = C(15,5) = 3,003
Answer: 15 even numbers in pool; 3,003 unique 5-number sets possible
Practice Questions
Try these on your own:
- What is the probability of rolling a 6 on a fair die? (Answer: 1/6 ≈ 16.67%)
- How many odd numbers exist between 1 and 50 inclusive? (Answer: 25)
- If generating 3 unique numbers from 1–10, how many possible sets exist? (Answer: 120)
- What is the expected average value when generating random numbers between 1 and 100? (Answer: 50.5)
- You flip a coin 10 times. What is the probability of getting all heads? (Answer: 1/1024 ≈ 0.098%)
- How many 4-digit PINs are possible using digits 0–9 with repetition allowed? (Answer: 10,000)
Common Mistakes to Avoid
A common misconception is the "gambler's fallacy" — believing that past random results influence future ones. Each generation is independent; getting 7 three times in a row does not make 7 less likely on the next draw. Another mistake is using Math.random() for security-sensitive purposes (passwords, tokens, encryption keys) — it is NOT cryptographically secure. Use window.crypto.getRandomValues() or a CSPRNG instead. When generating unique numbers, people forget to verify that their requested count does not exceed the pool size — you cannot draw 20 unique numbers from a pool of 10. Also, be aware that "random" does not mean "evenly spread" — a truly random sequence of 10 numbers from 1–100 might cluster together, and that is perfectly normal. Finally, off-by-one errors are common: the range from 1 to 10 inclusive contains 10 numbers, not 9.
Key Takeaways
- Random numbers from a uniform distribution have equal probability for each value in the range.
- For unique (no-duplicate) generation, the count cannot exceed the available pool size.
- The Fisher-Yates shuffle guarantees an unbiased permutation for unique number selection.
- Pseudorandom generators (like Math.random) are fine for games and simulations, but not for cryptography.
- The expected average of uniformly distributed integers from min to max is (min + max) / 2.
- Each random generation is independent — previous results do not affect future ones.