Skip to content
UniKit

Prime number generator

List every prime in any number range using a segmented sieve, with optional endpoint inclusion, ranges near 10⁹, plus count, sum and twin-prime statistics.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Number range

Prime results

Computed locally with a segmented sieve; above the display limit only the first and last half are printed, while statistics always use the full list.

Enter a range to see the primes and statistics

Primes found: 0 · Sum: 0 · Smallest prime: - · Largest prime: - · Twin prime pairs: 0

What this tool does

  • List every prime inside a range: 1-100 holds 25 of them and their sum is 1060.
  • Pick a prime for cryptography, hash table sizes or a random seed.
  • Inspect a narrow range near 10⁹ cheaply, because the sieve is segmented and never allocates the whole range.
  • Count twin prime pairs (3-5, 11-13, …) and primes in a range to check number theory exercises.

Example

Input

1,100 (endpoints included)

Output

25 primes in 1-100 (endpoints included)
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
Sum 1060, smallest 2, largest 97, twin prime pairs 8

1-1000 contains 168 primes with 997 as the largest; 1-1000000 contains 78498 with 999983 as the largest.

Frequently asked questions

Which algorithm is used?

A segmented sieve of Eratosthenes: first the primes up to sqrt(upper bound) are sieved, then the range is processed in blocks of at most one million numbers. That is why 999000000-999001000 works without allocating a gigabyte-scale array.

What does including or excluding endpoints mean?

Included (the default) treats the range as [a, b] so a prime endpoint counts; excluded uses (a, b). For 10-19 that is 4 primes (11, 13, 17, 19) versus 3 when the endpoints are excluded.

Why is 2000000-3000000 rejected?

A single request may span at most one million numbers and each bound must stay within 10⁹, which keeps every calculation fast. Split larger jobs into several ranges.

Is 1 prime?

No. A prime is a natural number greater than 1 whose only positive divisors are 1 and itself, so 1, 0 and negative numbers never appear; the range -10-10 returns 2, 3, 5, 7.

Can the output get very long?

Yes. Above the display limit (200 by default) the text keeps only the first and last half and states the total, while the returned data still holds the full list and all statistics use it.

Keywords:prime number generatorprimes in rangesegmented sieve

Related tools