Range Explorer [A, B]

Prime Numbers Between Two Numbers

Find every prime number between any two numbers. See the total count, sum, twin prime pairs, and gaps between primes.

Try Ranges:
Prime Count 1
Prime Sum 97
Density 10.0%
Twin Pairs 0
Prime Gap Range:
Smallest Gap: N/A Largest Gap: N/A
Primes in [90, 99]:
97
Showing 1 prime
01

Interactive Tool: Bertrand's Rule & Range Checker

Bertrand's Postulate guarantees that for every whole number n > 1, there is always at least one prime number between n and its double 2n. Test any starting number n below to see the guaranteed range [n, 2n], its prime count, observed density, and estimated count:

Quick Examples:
Bertrand's Rule Status: Verified (At least 1 prime exists)
Tested Range [50, 100] (51 numbers)
Actual Primes 10 primes
Prime Density 19.6%
Estimated Count ≈ 10.8 primes
Primes in Range [n, 2n]:
53 59 61 67 71 73 79 83 89 97
02

Including vs. Excluding the End Numbers

Whether you include the starting and ending numbers makes a big difference when those numbers are prime themselves. Compare [7, 19] (includes 7 and 19) versus (7, 19) (strictly between):

Primes Included: 7, 11, 13, 17, 19
Total Count: 5 primes
03

Milestone Number Ranges

Click any range below to test the calculator, see all prime numbers, and explore prime deserts:

Range [A, B] Prime Count Density Prime Sum Why It Matters Action
[1, 100] 25 25.0% 1,060 Standard elementary benchmark; first 25 primes
[90, 99] 1 10.0% 97 The famous "90s desert" where only 97 is prime
[100, 200] 21 20.8% 3,167 Second century; 21 primes including twins (101, 103)
[114, 126] 0 0.0% 0 Complete prime desert of length 13 between 113 and 127
[200, 300] 16 15.8% 3,997 Third century; thinning law in effect
[300, 400] 16 15.8% 5,584 Fourth century; steady prime frequency
[500, 600] 14 13.9% 7,705 Mid-millennium interval
[888, 906] 0 0.0% 0 Prime desert of length 19 between 887 and 907
[900, 1000] 14 13.9% 13,382 Final century of the first millennium; ending at 997
[1000, 1100] 16 15.8% 16,778 Opening century of second millennium; starts at 1009
[1330, 1360] 0 0.0% 0 Substantial prime desert between 1327 and 1361
[2, 4] 2 66.7% 5 Bertrand interval for n = 2: primes 2, 3
[10, 20] 4 36.4% 60 Bertrand interval for n = 10: 11, 13, 17, 19
[50, 100] 10 19.6% 732 Bertrand interval for n = 50: 10 primes found
[100, 200] 21 20.8% 3,167 Bertrand interval for n = 100: Chebyshev verification
[524, 540] 0 0.0% 0 Desert between consecutive primes 523 and 541
[9900, 10000] 11 10.9% 109,477 Final hundred before 10,000; ends at 9973
[10000, 10100] 11 10.9% 110,509 First hundred above 10,000; starts at 10007
[19610, 19660] 0 0.0% 0 Large prime desert between 19609 and 19661
[100000, 100100] 6 5.9% 600,274 6-digit density; demonstrates 1/ln(x) thinning
04

Rules & Theorems for Primes in a Range

1. Counting Primes in a Range

The prime counting function π(x) counts how many primes exist up to x. For any range between A and B:

π([A, B]) = π(B) - π(A - 1)

Subtracting π(A - 1) ensures that if the starting number A is prime, it is properly counted in your range. For open ranges (A, B) that leave out both endpoints, the formula becomes π(B - 1) - π(A).

2. Bertrand's Postulate

Proven in 1852 by mathematician Pafnuty Chebyshev:

For every whole number n > 1, there is always at least one prime p between n and 2n

This guarantees that you will never find an empty prime desert that doubles your starting number.

3. Primes Between Square Numbers (Legendre's Conjecture)

Mathematician Adrien-Marie Legendre conjectured that there is always at least one prime number between consecutive square numbers:

For every n ≥ 1, there is a prime between n² and (n + 1)²

For example, between 4² = 16 and 5² = 25, you find primes 17, 19, and 23. While computers have verified this up to huge numbers, an absolute mathematical proof remains an open challenge.

Difference in pi(x) prime count growth curve showing primes between B and A equals pi(B) - pi(A-1)
Counting Interval Primes as π(B) − π(A − 1) Subtraction along the smooth Prime Counting curve explains how many primes inhabit any custom window [A, B].
05

Step-by-Step Worked Examples

Follow these 4 clear walkthroughs to see how to find primes, check range boundaries, and avoid common number traps:

Example 1

Primes in [90, 99] — The 90s Desert

Step 1: List all 10 integers: 90 through 99.
Step 2: Eliminate even numbers: 90, 92, 94, 96, 98.
Step 3: Eliminate multiples of 5: 95.
Step 4: Check remaining odds: 91, 93, 97, 99.
• 91 = 7 × 13 (not prime)
• 93 = 3 × 31 (divisible by 3)
• 99 = 9 × 11
Conclusion: Only 97 is prime. Count = 1, Sum = 97.

Example 2

Primes in [1, 25] — The First Quarter-Century

Step 1: Check primes up to √25 = 5 (primes 2, 3, 5).
Step 2: Note that 1 is neither prime nor composite.
Step 3: Cross out multiples of 2, 3, and 5 up to 25.
Primes Found: 2, 3, 5, 7, 11, 13, 17, 19, 23.
Metrics: Count = 9, Sum = 100, Density = 36.0%.
Twin Pairs: (3, 5), (5, 7), (11, 13), (17, 19).

Example 3

Doubling from 50 to 100 — Bertrand's Rule

Question: Does a prime exist strictly between 50 and 100?
Search: Primes found between 50 and 100 are 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
Verification: Exactly 10 primes found, easily satisfying Bertrand's rule.
Prime Gaps: Gaps between consecutive primes are 6, 2, 6, 4, 2, 6, 4, 6, 8.

Example 4

Segmented Sieve from 1,000 to 1,050

Range Size: 1050 - 1000 + 1 = 51 numbers.
Primes Needed: Up to √1050 ≈ 32.4 (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31).
Cross-Out: Cross out multiples of each small prime inside just this 51-number window.
Primes Found: 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049.
Count: 8 primes; Prime sum = 8,215.

06

How Fast Can Computers Find Primes in a Range?

Finding primes inside a range [A, B] uses different computer strategies depending on the size of the numbers:

Method Speed (Time Steps) Memory Used Best Used For Tested Speed
Checking Each Number One by One Slow for wide ranges Tiny Very narrow spans (under 100 numbers) ~250,000 numbers/sec
Full Array Sieve (Standard Sieve) Fast, but uses lots of RAM High memory for big numbers Ranges starting near 0 ~15,000,000 numbers/sec
Segmented Sieve (Our Engine) Fastest for ranges Small (fits in CPU cache) Ranges anywhere on the number line ~50,000,000 numbers/sec
Fast Counting Formula (Meissel-Lehmer) Fastest for counting Moderate Counting primes up to 10²² without listing them Billions
07

Real-World Uses for Primes in a Range

Computer Encryption (RSA)

Security algorithms like RSA require generating random prime numbers with an exact number of digits (such as 300 digits). Computer programs choose a range of that size and search inside it to find secure prime keys.

Database Hash Tables

Fast databases like Redis and PostgreSQL resize their hash tables to the next prime number in a range to distribute data evenly and prevent search slowdowns.

Supercomputer Processing

When supercomputers search for new prime numbers, they split giant spans into smaller segments so thousands of processors can search side-by-side without getting in each other's way.

Related Prime Discovery Tools

Frequently Asked Questions

Are the start and end numbers included in the calculation?

Yes! Standard calculations include both endpoints [A, B]. If the start or end number is prime, it is counted in the total and shown in the list. You can also explore open intervals (A, B) that leave out the endpoints in our boundary section below.

What is the only prime number between 90 and 99?

97 is the only prime number between 90 and 99. All other numbers in this range are composite, including common trick numbers like 91 (7 × 13) and 93 (3 × 31).

What does Bertrand's Postulate say about primes between numbers?

Bertrand's Postulate guarantees that for any whole number n greater than 1, there is always at least one prime number between that number and its double (between n and 2n). For example, between 10 and 20, you will always find primes (11, 13, 17, 19).

What happens if there are no primes in the selected range?

If a range contains no prime numbers (such as between 114 and 126), this is called a 'prime desert' or prime gap. The calculator clearly reports 0 primes found and shows the gap size.

What is a twin prime pair inside a range?

Twin primes are pairs of prime numbers that are separated by just 2, such as (3, 5), (11, 13), and (71, 73). The calculator automatically detects and counts all twin prime pairs whose numbers both lie inside your range.

How does the calculator find primes between large numbers so quickly?

Instead of checking every number from 0 upwards, the calculator uses a segmented sieve. It only checks primes up to the square root of your maximum number, focusing its power directly on your chosen range.

How are prime gaps calculated within the range?

A prime gap is the distance between two consecutive prime numbers. The calculator measures the difference between each pair of adjacent primes in your range and highlights the smallest and largest gaps.

What is Legendre's conjecture regarding primes between numbers?

Legendre conjectured that there is always at least one prime number between consecutive square numbers (like between 3² = 9 and 4² = 16, which contains 11 and 13). Computers have verified this for huge numbers, though mathematicians are still working on a complete proof.