Prime and composite numbers
A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself: 2, 3, 5, 7, 11, 13 … A whole number greater than 1 that is not prime is composite: it can be written as \(n = a \cdot b\) with \(1 < a \le b < n\). The number 1 is neither prime nor composite.
By the fundamental theorem of arithmetic, every whole number \(n > 1\) is a product of primes in exactly one way (apart from order):
Trial division and the square-root limit
If \(n = a b\) with \(a \le b\), then \(a \cdot a \le a b = n\), so \(a \le \sqrt{n}\). Therefore
Only primes need to be tried, because any composite divisor has a smaller prime divisor. For very large numbers the app uses the Miller–Rabin test with fixed bases, which is exact (deterministic) for every number in its range, and then factors composite numbers.
Worked example
Example
Is 1001 prime? \(\sqrt{1001} \approx 31.6\), so try the primes 2, 3, 5, 7, … up to 31.
- 2: 1001 is odd – no.
- 3: digit sum 2 – no.
- 5: last digit 1 – no.
- 7: 1001 = 7 · 143 – yes.
So 1001 is composite. Continuing with 143 = 11 · 13 gives \(1001 = 7 \cdot 11 \cdot 13\), with \(2 \cdot 2 \cdot 2 = 8\) divisors: 1, 7, 11, 13, 77, 91, 143, 1001.
Is 97 prime? \(\sqrt{97} \approx 9.85\). None of 2, 3, 5, 7 divides 97, so 97 is prime.
Divisor count and sum
For \(1001 = 7 \cdot 11 \cdot 13\): \(\tau = 8\) and \(\sigma = 8 \cdot 12 \cdot 14 = 1344\).
How primes are spread
There are infinitely many primes (Euclid). They get rarer as numbers grow: the prime number theorem says the number of primes up to \(x\) is about
There are 25 primes below 100, 168 below 1000 and 78 498 below one million.
Sieve of Eratosthenes
To list all primes in a range, write the numbers down, then cross out the multiples of 2, 3, 5, 7, … starting from \(p^2\). What remains is prime. The range tab uses this sieve.
FAQ
Why is 1 not a prime number?
A prime has exactly two different divisors. 1 has only one. Leaving 1 out also keeps prime factorizations unique.
Is 2 the only even prime?
Yes. Every other even number is divisible by 2, so it has at least three divisors.
What are twin primes?
Primes that differ by 2, such as 11 and 13 or 71 and 73. Whether there are infinitely many is still an open question.
How large a number can I test?
Up to 10^15 (one quadrillion). The answer is exact for every number in this range.
