Xerobit

Prime Numbers List: Generate, Find Nth, and Range

Enter a limit, an index, or a range to get a prime numbers list instantly. The tool uses a Sieve of Eratosthenes and runs entirely in your browser with no data uploaded.

Choose what kind of prime list you need.

Primes

  1. 2
  2. 3
  3. 5
  4. 7
  5. 11
  6. 13
  7. 17
  8. 19
  9. 23
  10. 29
  11. 31
  12. 37
  13. 41
  14. 43
  15. 47
  16. 53
  17. 59
  18. 61
  19. 67
  20. 71
  21. 73
  22. 79
  23. 83
  24. 89
  25. 97

How to use the prime numbers list

  1. Pick a mode from the dropdown: primes up to a limit, the nth prime, the next prime after a value, or primes in a range.
  2. Enter the required number(s) for that mode. Each field has a sensible default.
  3. Press Generate to run the sieve and produce the list.
  4. Copy the primes from the result area; they are plain numbers separated by commas.

How the Sieve of Eratosthenes works

The Sieve of Eratosthenes finds all primes up to a limit N by crossing out multiples of each prime starting from 2. Create a boolean array of size N+1 initialized to true. For each p from 2 to sqrt(N), if p is still marked true, mark all multiples p*p, p*(p+1), ... as false. The indices still true at the end are primes.

Worked example for N=30: start with 2, cross out 4,6,8,...,30. Next uncrossed is 3, cross out 9,12,15,...,30. Next is 5, cross out 25,30. Next is 7, but 7*7=49 > 30 so stop. Remaining: 2,3,5,7,11,13,17,19,23,29.

Reference: first 100 primes and counts

The table below shows the first 100 primes and the cumulative count π(x) (primes ≤ x) at several milestones. Use it to verify the tool or to pick an N for the "up to N" mode.

IndexPrimeIndexPrimeIndexPrimeIndexPrime
12261015123376383
23271035223977389
35281075324178397
47291095425179401
511301135525780409
613311275626381419
717321315726982421
819331375827183431
923341395927784433
1029351496028185439
1131361516128386443
1237371576229387449
1341381636330788457
1443391676431189461
1547401736531390463
1653411796631791467
1759421816733192479
1861431916833793487
1967441936934794491
2071451977034995499
2173461997135396503
2279472117235997509
2383482237336798521
2489492277437399523
25975022975379100541

Prime counts: π(10)=4, π(100)=25, π(1,000)=168, π(10,000)=1,229, π(100,000)=9,592, π(1,000,000)=78,498, π(10,000,000)=664,579.

Practical use cases

Use this prime numbers list generator for cryptography, hash tables, number theory, teaching, and programming challenges.

  • Cryptography: RSA key generation needs large random primes; this tool helps explore small primes for learning.
  • Hash tables: Prime-sized arrays reduce collisions in modular hashing.
  • Number theory: Verify conjectures (Goldbach, twin primes) by generating lists.
  • Teaching: Show students the sieve visually or print the first N primes for worksheets.
  • Programming challenges: Quickly get test inputs for prime-related algorithms.

Common mistakes and edge cases

The prime numbers list tool starts at 2; entering a range that includes 1 will not list it.

  • Invalid inputs such as decimals, blank fields or values outside the allowed range return an error instead of a list.
  • Large N performance: The browser sieve is capped at 10,000,000. Beyond that, use a segmented sieve or a server-side tool.
  • Nth prime upper bound: For the nth prime mode, the tool estimates an upper bound using n * (log n + log log n) for n ≥ 6, then sieves up to that bound. If the estimate is too low (rare for n ≤ 1,000,000), it doubles and retries.
  • Next prime after a huge number: The tool checks odd candidates with trial division up to sqrt(candidate). The start value is capped at 10,000,000, and the search may run slightly past that (the next prime after 10,000,000 is 10,000,019).

Prime distribution and the Prime Number Theorem

The Prime Number Theorem states that π(x) ~ x / ln(x). A sharper approximation is the logarithmic integral Li(x). For example, π(1,000,000) = 78,498 while 1,000,000 / ln(1,000,000) ≈ 72,382 (error ~8%). The nth prime p_n ~ n ln n; the 1,000,000th prime is 15,485,863 while 1,000,000 * ln(1,000,000) ≈ 13,815,510. The tool uses these approximations only to set sieve bounds; the output is exact.

Worked examples

ExampleInputResult
Primes up to 100Mode: upto; Maximum N: 1002, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
The 100th primeMode: nth; N (which prime): 1002, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541
Next prime after 1000Mode: next; Start value: 10001009
Primes between 50 and 150Mode: range; From (inclusive): 50; To (inclusive): 15053, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149
First 20 primesMode: nth; N (which prime): 202, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71

FAQ

Is 1 a prime number?

No. By definition a prime has exactly two positive divisors: 1 and itself. The number 1 has only one divisor, so it is excluded. This tool starts at 2.

What is the largest prime this tool can find?

The sieve caps at 10,000,000 for the "up to N" and "range" modes, giving 664,579 primes. For "nth prime" you can request up to the 1,000,000th prime (15,485,863) because the tool estimates a bound and sieves up to it.

How does the nth prime calculator work?

It estimates an upper bound using the Rosser-Schoenfeld inequality p_n < n(ln n + ln ln n) for n ≥ 6, runs the sieve up to that bound, and returns the nth element. If the bound was too low, it doubles and retries.

Can I get primes between two numbers?

Yes. Choose "Primes between A and B" mode, enter the inclusive lower and upper bounds, and press Generate. The tool sieves up to B and filters the result.

Why is 2 the only even prime?

Any even number greater than 2 is divisible by 2, so it has at least three divisors (1, 2, itself). Therefore no even number > 2 can be prime.

How accurate is the prime number theorem approximation?

The relative error of x/ln(x) decreases slowly; at 10^9 it is about 5%. The tool does not use the approximation for results, only to size the sieve, so output is always exact.

Does this tool work offline?

Yes. The page loads the logic as a static module; once loaded, generation runs entirely in your browser with no network requests.