Prime Number Generator (Primes in a Range)
List every prime number between two values up to one billion, with the count, sum, twin primes and largest gap, using the sieve of Eratosthenes.
Results are rounded for display. Check important answers, especially in assessed or technical work.
What is a prime number?
A prime number is a whole number greater than 1 whose only divisors are 1 and itself, such as 2, 3, 5 and 7. Primes are the building blocks of all whole numbers, because every number above 1 can be written as a product of primes in exactly one way.
How to use this calculator
Enter the start and end of a range. The calculator sieves the range for primes and lists them (the first 300 are shown), with summary statistics. Ranges can reach up to 1,000,000,000 and span up to 2,000,000 numbers.
Formula
A prime has exactly two divisors, 1 and itself. Sieve of Eratosthenes: list the primes up to √(end), then cross out every multiple of each of them in the range. The numbers left are prime.
Terms in the formula
- Prime
- A number with exactly two divisors.
- Twin primes
- Primes that differ by 2.
- Gap
- Difference between consecutive primes.
Understanding your result
The list shows every prime in your range. The count shows how dense primes are there; they thin out as numbers grow but never stop. Twin primes and the largest gap describe how irregularly they are spaced, which is one of the oldest open questions in mathematics.
Calculator credits
Calculator developmentJulia Edwards
Editorial supervisionSamad Aslam Khan
Expert reviewIfrahMSc Mathematics
Published byThe Calculatorz
Last updated
Read how we research, test, review and correct our calculators in our editorial policy.
Frequently asked questions
Is 1 a prime number?
No. A prime has exactly two different divisors, and 1 has only one. 2 is the smallest prime and the only even one.
How many primes are there below 1,000?
168. Below 100 there are 25, and below 1,000,000 there are 78,498.
What are twin primes?
Pairs of primes that differ by 2, such as 11 and 13 or 41 and 43. It is not known whether there are infinitely many.
Why do primes become rarer?
Larger numbers have more possible factors. Near a number N, roughly one number in ln N is prime, so around one million about 1 in 14 numbers is prime.
What is the sieve of Eratosthenes?
An ancient method for finding primes: start with a list of numbers and cross out the multiples of each prime in turn. What remains is prime.
How do I check if one number is prime?
Use the divisors calculator, or enter the same number as both the start and end of the range here.
References & methodology sources
These sources support the calculator’s formula, definitions, thresholds, units or result interpretation.
- Weisstein, E. W. (n.d.). Prime number. MathWorld—A Wolfram Web Resource. View source
- Weisstein, E. W. (n.d.). Sieve of Eratosthenes. MathWorld—A Wolfram Web Resource. View source
- OEIS Foundation. (n.d.). A000040: The prime numbers. The On-Line Encyclopedia of Integer Sequences. View source
- Marecek, L., Anthony-Smith, M., & Honeycutt Mathis, A. (2020). Prime factorization and the least common multiple. In Prealgebra 2e (Section 2.5). OpenStax. View source