Skip to content
MoneyDeck

Prime Number Generator

List every prime in a range, or the first n primes, with a fast sieve

Updated · Free, no signup

Range width up to 1,000,000; upper limit 10¹³.

Primes found

25

Prime numbers

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

Smallest prime

2

Largest prime

97

Sum of the primes

1060

Twin prime pairs (p, p + 2)

8

Share of numbers that are prime

25%

Largest gap between consecutive primes

8

  • The prime number theorem predicts about 25 primes in a window this size around 51 (width ÷ ln of the midpoint); the sieve found 25.

Primes per interval

About the Prime Number Generator

This prime number generator lists every prime in a range you choose — say 1 to 100 or 1,000 to 2,000 — or the first n primes, up to the 10,000th prime. Alongside the list you get the number of primes found, their sum, the smallest and largest, how many twin-prime pairs (primes two apart) occur, and a chart of how the primes are spread across the range.

It is useful for students exploring number theory, teachers making worksheets, programmers who need test data, and puzzle-solvers checking a hunch. Ranges can reach as high as ten trillion (10¹³) as long as the window is at most one million numbers wide, so you can look for primes near very large numbers too.

Under the hood it uses the sieve of Eratosthenes — a segmented version for high ranges — so results are exact, not probabilistic. Up to 2,000 primes are printed; counts and sums always cover the whole range.

With the default inputs, the primes found is 25. Change any value above to recalculate instantly.

How to use the prime number generator

  1. 1Choose whether you want primes in a range or the first n primes.
  2. 2Enter the start and end of the range (or how many primes you want).
  3. 3Read the count of primes found and copy the list.
  4. 4Check the sum, largest gap and twin-prime count for extra detail.
  5. 5Use the chart to see how primes thin out across the range.

Formula and method

Sieve: for each prime p ≤ √N, cross out p², p² + p, p² + 2p, …; π(N) ≈ N / ln N

The sieve of Eratosthenes writes down the numbers 2…N and, for each prime p in turn, crosses out its multiples starting at p² (smaller multiples were already crossed out by smaller primes). Whatever is never crossed out is prime. Only primes up to √N are needed, because any composite number has a factor no larger than its square root.

For a range far from zero, a segmented sieve first finds the primes up to √(upper limit) and then crosses out their multiples inside the window only, so a window near one trillion takes the same effort as one near zero. The prime number theorem, π(N) ≈ N/ln N, explains why primes thin out: near N roughly one number in ln N is prime.

N
Upper limit of the search
p
A prime used to cross out multiples
π(N)
Number of primes ≤ N

Worked examples

Primes from 1 to 100

There are 25 primes below 100: 2, 3, 5, 7, 11, …, 89, 97. They add up to 1,060, and 8 pairs are twin primes: (3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43), (59, 61) and (71, 73).

The first 10 primes

The first ten primes are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29, which sum to 129.

Primes between 1,000 and 2,000

The sieve finds 135 primes in this range, starting at 1,009 and ending at 1,999 — fewer than the 168 primes below 1,000, because primes thin out as numbers grow.

Primes just above one trillion

A segmented sieve checks the 1,001 numbers from 10¹² to 10¹² + 1,000 and finds 37 primes, close to the prime-number-theorem estimate of 1,001 ÷ ln(10¹²) ≈ 36.

Frequently asked questions

How many prime numbers are there between 1 and 100?+

There are 25 primes up to 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97. There are 168 primes up to 1,000.

How does the sieve of Eratosthenes work?+

List the numbers from 2 up to N. Circle 2 and cross out every multiple of 2; move to the next uncrossed number, circle it, and cross out its multiples. Repeat until you pass √N — every number left uncrossed is prime.

Is 1 a prime number?+

No. A prime has exactly two distinct positive divisors, 1 and itself; 1 has only one divisor. Excluding 1 keeps prime factorisation unique, so this generator starts at 2.

What are twin primes?+

Twin primes are pairs of primes that differ by 2, such as (11, 13) or (1,019, 1,021). It is still unproven whether there are infinitely many, a famous open problem called the twin prime conjecture.

Are there infinitely many primes?+

Yes. Euclid proved it around 300 BC: multiply any finite list of primes together and add 1; the result has a prime factor not on the list. Primes do become rarer — near N about one number in ln N is prime.

Related tools