Prime Number Generator
Generate custom lists of prime numbers between two numbers, list primes up to an upper limit, or output the exact first N primes with instant CSV, JSON, or text export.
Multi-Language Output Formatter & Exporter
Need prime numbers formatted for your code, spreadsheet, or database query? Click any format below to instantly reformat your generated list:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
02. Prime Density Scanner & Prediction Checker
Test any number range using a fast sieve scan to compare the real prime count against the theoretical prediction from the Prime Number Theorem:
03. Landmark Prime Generation Ranges
20 milestone ranges and sequence counts. Click "Generate" to load them into the calculator:
| Range / Query | Type | Prime Count | Density % | Smallest & Largest | Action |
|---|---|---|---|---|---|
| [1, 100] | range | 25 | 25.00% | [2, 97] · First century; 25 primes | |
| [100, 200] | range | 21 | 21.00% | [101, 199] · Second century; density drops to 21% | |
| [200, 300] | range | 16 | 16.00% | [211, 293] · Third century; 16 primes | |
| [500, 600] | range | 14 | 14.00% | [503, 599] · Mid-hundreds interval | |
| [1,000, 1,100] | range | 16 | 16.00% | [1009, 1097] · Four-digit threshold interval | |
| [10,000, 10,100] | range | 11 | 11.00% | [10007, 10099] · Five-digit interval; 11 primes | |
| Up to 100 | upto | 25 | 25.00% | [2, 97] · All primes up to 100 | |
| Up to 500 | upto | 95 | 19.00% | [2, 499] · All primes up to 500 | |
| Up to 1,000 | upto | 168 | 16.80% | [2, 997] · Millennium milestone π(1000) = 168 | |
| Up to 5,000 | upto | 669 | 13.38% | [2, 4999] · All primes up to 5,000 | |
| Up to 10,000 | upto | 1229 | 12.29% | [2, 9973] · Five-digit milestone π(10,000) = 1,229 | |
| First 10 Primes | firstN | 10 | 34.48% | [2, 29] · First 10 primes end at 29 | |
| First 25 Primes | firstN | 25 | 25.00% | [2, 97] · First 25 primes span 1 to 97 | |
| First 50 Primes | firstN | 50 | 21.83% | [2, 229] · First 50 primes span up to 229 | |
| First 100 Primes | firstN | 100 | 18.48% | [2, 541] · Centennial prime p₁₀₀ = 541 | |
| First 250 Primes | firstN | 250 | 15.46% | [2, 1619] · First 250 primes up to 1,619 | |
| First 500 Primes | firstN | 500 | 14.00% | [2, 3571] · First 500 primes up to 3,571 | |
| First 1000 Primes | firstN | 1000 | 12.63% | [2, 7919] · Millennium prime p₁₀₀₀ = 7,919 | |
| [100,000, 100,100] | range | 6 | 6.00% | [100003, 100069] · Six-digit interval thinning | |
| [1,000,000, 1,000,100] | range | 8 | 8.00% | [1000003, 1000099] · One million mark interval |
04. How Primes Thin Out as Numbers Grow
A fundamental discovery in mathematics is that prime numbers do not appear at fixed intervals. Instead, they gradually thin out following the natural logarithm:
Near 100, roughly 1 in every 4.6 numbers is prime (about 22%). Near 1,000,000, only 1 in every 14 numbers is prime (about 7%). Near 1 quintillion (10¹⁸), density drops to roughly 1 in 41 numbers.
05. Step-by-Step Worked Examples
Cross out multiples of 2, 3, 5, and 7 up to √100 = 10. Exactly 25 primes survive. Smallest is 2, largest is 97. Total sum is 1,060.
Tested by checking prime factors up to √1100 ≈ 33.1 (checking primes up to 31). Finds 16 primes: 1009, 1013, 1019, ..., 1097. Sum = 16,846.
Listing the primes in order from 1st to 50th. The 50th prime is 229. Total sum equals 5,117.
For numbers above 100,000, our tool checks 7 proven test bases (Miller-Rabin). It skips even numbers and multiples of 3, giving 100% accuracy.
06. Real-World Uses for Generated Primes
Security algorithms like RSA and Diffie-Hellman require generating large random prime numbers. Prime generators test random odd candidates until confirmed primes are found.
Fast hash tables and dictionaries resize their internal memory buckets to prime numbers to distribute keys evenly and prevent performance slowdowns.
Financial and scientific simulations use low-discrepancy point sequences whose coordinates are built using consecutive prime bases (2, 3, 5, 7, 11).
Bluetooth and radar systems hop frequencies using prime number patterns to prevent interference and signal jamming.
07. Prime Generation Methods Compared
| Method | Speed (Time Steps) | Memory Used | How It Works | Best Used For |
|---|---|---|---|---|
| Sieve of Eratosthenes | Fast sweep | Small (1 bit/number) | Crosses out multiples step by step | Dense primes up to 10,000,000 |
| Segmented Sieve | Fast block sweep | Tiny (fits in CPU cache) | Processes numbers in small blocks | High ranges [A, B] up to 1 trillion |
| 7-Base Miller-Rabin Check | Very fast for single numbers | Tiny (fixed) | Clock-math power checks | Big numbers up to 18 quintillion |
| Checking One by One | Slowest | Tiny (fixed) | Divides by one factor at a time | Small numbers (under 1,000) |
Related Sequence & Interval Calculators
Frequently Asked Questions
How does this prime number generator find primes so quickly?
The generator uses an instant lookup table for numbers up to 105,000, and switches to a fast number grid sieve and our exact 7-base prime check for larger numbers. This creates thousands of primes in milliseconds right inside your browser.
What is the difference between 'Primes up to N' and 'First N Primes'?
'Primes up to N' finds all prime numbers that are less than or equal to N (for example, primes up to 10 gives 4 primes: 2, 3, 5, 7). 'First N Primes' counts out the first N prime numbers in a row (for example, the first 10 primes gives: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29).
What is prime density?
Prime density is the percentage of numbers in a range that are prime. It is calculated by dividing the number of primes by the total numbers in that range. As numbers get bigger, primes naturally thin out, following the rule 1 / ln(x).
Can I export or copy the generated prime list?
Yes! You can copy the entire list to your clipboard in standard formats (CSV, JSON, Python list, SQL, or space-separated) or download it as a plain-text (.txt) file with one click.
What are the maximum generation limits?
To keep your browser fast and responsive, the tool allows ranges up to 20,000 numbers and first-N lists up to 5,000 primes. Everything runs 100% on your device with zero delay.
Is the test used by this generator 100% accurate?
Yes! For all 64-bit numbers (up to 18 quintillion), testing 7 specific prime bases guarantees 100% accuracy with zero false positives or missed primes.
How does the Prime Number Theorem estimate the number of primes?
The Prime Number Theorem (PNT) shows that the number of primes up to x is roughly x / ln(x). In any range between A and B, this formula predicts the prime count with remarkable accuracy.