How this calculation works
The endpoints count when prime. For an interval starting at 0 or 1, the first possible listed value is 2.
Count integers with no divisors from 2 through their square rootA worked example
There are six primes between 10 and 30, from 11 through 29.
Good to know
Both endpoints are included.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
Count the included endpoints and the integers between them
The inclusive interval from 10 to 30 contains 21 integers. Testing them leaves the primes 11, 13, 17, 19, 23 and 29, so the count is six. The list and count should agree. The number 21 is excluded because it factors as 3 × 7, and 25 is excluded because it is 5².
Both endpoints are included. Changing the interval to 11 through 29 keeps all six primes. Moving the lower bound to 12 removes 11 and leaves five. The calculator tests integers individually against possible divisors up to their square roots, using the same reasoning as the Prime number test calculator.
Read a prime count without assuming regular spacing
The gaps in the displayed list are 2, 4, 2, 4 and 6. Prime numbers do not occur at a fixed spacing. A long gap between two primes in one interval does not establish the size of the next gap. The count describes the specified interval only.
An interval can contain no primes, such as 24 through 28. A single-point interval returns one prime exactly when that endpoint is prime. The upper bound must be at least the lower bound. Values below two are accepted as interval endpoints, but they contribute no primes because neither zero nor one is prime.
A few questions, answered
Does 10 through 30 contain twenty integers?
It contains twenty-one because the bounds are inclusive. The count of integers is upper − lower + 1.
Can the lower and upper bounds be equal?
Yes. An interval containing only 13 returns the single prime 13, while one containing only 14 returns none.