Prime Number Checker
Two modes: check if any number is prime (with next/previous prime and smallest factor), or list all primes in any range up to 10,000 wide.
You might also need
How It Works
Enter any positive integer and press Check. The algorithm tests divisibility by 2, then odd numbers up to √n. If no divisor is found, the number is prime. If composite, the smallest prime factor displays — this lets you start factoring without a separate tool. The next prime above and previous prime below your number also display automatically.
Trial division: test 2, then odd k from 3 to √n97 → PRIME (no divisors up to √97≈9.85) | 91 = 7×13 → factor: 7Switch to Primes in Range. Enter start and end values (range up to 10,000 wide). All primes in the interval display in a grid, with the count shown at the top. Examples: primes 1–100 = 25 primes. Primes 1000–1100 = 16 primes. Primes 1–1000 = 168 primes. The count confirms the prime counting function π(n).
π(100)=25 | π(1000)=168 | π(10000)=1229Range 1–20: 2,3,5,7,11,13,17,19 (8 primes)When a number is composite, the smallest prime factor shows immediately. This is the first step of prime factorization. For 2024: smallest factor = 2 (even number). For 91: smallest factor = 7 (91 = 7×13). For 561 (Carmichael number): smallest factor = 3 (561 = 3×11×17). Divide by the smallest factor, then check the quotient in a new calculation to build the full factorization.
composite n → smallest prime factor p → n/p is next to factor100 → factor 2 → 50 → factor 2 → 25 → factor 5 → 5 (prime)A prime gap is the difference between consecutive primes. Gap after 2 is 1 (to 3). After 3 is 2 (to 5). After 7 is 4 (to 11). Twin primes differ by 2: (3,5), (5,7), (11,13), (17,19), (29,31). Use Primes in Range to find all twin prime pairs in a range. The twin prime conjecture (unproven) states there are infinitely many twin prime pairs.
Twin primes: p and p+2 are both primeRange 1–50: twin pairs (3,5), (5,7), (11,13), (17,19), (29,31), (41,43)π(n) counts how many primes are at most n. Key values: π(10)=4, π(100)=25, π(1000)=168, π(10000)=1229. The prime number theorem says π(n) ≈ n/ln(n). Primes become less dense as numbers grow but never stop — by the prime counting function, about 1 in ln(n) integers near n is prime. Near n=10000: about 1 in 9.2.
π(n) ≈ n/ln(n) (prime number theorem)π(1000)=168 ≈ 1000/ln(1000)=1000/6.91≈145 (rough approximation)Quick Reference
Verify these in the calculator above.
Check
Is 2 prime?
Yes — only even prime
Check
Is 1 prime?
No — neither prime nor composite
Check
Is 97 prime?
Yes
Check
Is 91 prime?
No — 7 × 13
Range
Primes 1–20
8 primes
Range
Primes 1–100
25 primes
Range
Twin primes near 30
29 and 31
Next prime
Next prime after 100
101
Tips & Shortcuts
For the fastest prime check of a large number, enter it in Check Number mode — trial division up to √n is very fast for numbers up to a few million.
To find twin prime pairs, use Primes in Range and look for consecutive primes that differ by 2 — they appear frequently below 1000.
When a number is composite, divide by the smallest factor shown, then re-enter the quotient to continue factoring. Repeat until prime for full prime factorization.
The range in Primes in Range can be up to 10,000 wide. For all primes below 1000, enter start=2 and end=1000.
Every even number greater than 2 is composite (divisible by 2) — you only need to check odd numbers manually.
Common Mistakes
Thinking 1 is prime
By definition, primes have exactly two distinct divisors. 1 has only one (itself) so it is not prime. The calculator correctly identifies 1 as neither prime nor composite.
Assuming all odd numbers are prime
Odd composites include 9 (3×3), 15 (3×5), 21 (3×7), 25 (5×5), 35 (5×7). Being odd is necessary but not sufficient for primality. The calculator checks all odd divisors up to √n.
Entering the range backwards (start > end)
In Primes in Range, start must be less than or equal to end. The calculator shows an error if start exceeds end — just swap the values.
Expecting ranges larger than 10,000 to work
The Primes in Range mode limits the range to 10,000 integers for performance. For very wide ranges, run multiple consecutive searches (0–10000, 10000–20000, etc.).
Confusing prime with odd
The only even prime is 2. All primes above 2 are odd, but not all odd numbers are prime. 9, 15, 21, 25, 27, 33... are all odd composites.
Frequently Asked Questions
A prime is a natural number greater than 1 with exactly two divisors: 1 and itself. First primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. The number 2 is the only even prime — all other even numbers are divisible by 2. The number 1 is neither prime nor composite by definition.
No. Prime numbers must have exactly two distinct positive divisors. The number 1 has only one divisor (itself), so it fails the definition. This exclusion is not arbitrary — it preserves the Fundamental Theorem of Arithmetic: every integer greater than 1 factors into primes in exactly one way. If 1 were prime, factorizations would not be unique (12 = 2²×3 = 1×2²×3 = 1²×2²×3...).
Enter any positive integer and press Check. The algorithm tests divisibility by 2, then all odd numbers from 3 up to √n. If n=97: √97≈9.85, so test 2,3,5,7,9 — none divide 97, so 97 is prime. If composite, the smallest prime factor shows immediately (e.g. for 91: smallest factor is 7, since 91=7×13). The next prime above and previous prime below also display.
Switch to the Primes in Range tab. Enter start and end values — the range can be up to 10,000 integers wide. All primes in the interval display in a grid with the total count. Example: primes from 1 to 100 gives 25 primes (2,3,5,...,97). Useful for finding twin primes (pairs differing by 2: 11&13, 17&19, 29&31) or studying prime density.
Trial division (used here): test divisibility by all integers from 2 to √n. For n=10,000, only test up to 100. Optimization: check 2 first, then odd numbers only (skips even composites). For very large numbers, the Miller-Rabin probabilistic test is faster — it does not factor n, just tests primality with very high certainty.
Yes — Euclid's proof from 300 BC: suppose only finitely many primes p₁, p₂, ..., pₙ exist. Form N = p₁×p₂×...×pₙ + 1. N leaves remainder 1 when divided by any known prime, so N is either itself prime or has a prime factor not in our list — contradiction. Therefore the list of primes has no finite end.
As of 2024, 2^136279841 − 1 is the largest known prime — a Mersenne prime with over 41 million digits, discovered in October 2024 by the GIMPS project. Mersenne primes have the form 2^p − 1 where p itself must be prime. Not all prime p give Mersenne primes, but all known record-holders are Mersenne primes because efficient tests exist for them.
Related Calculators
Common Factor Calculator
Find all common factors of two or more numbers.
GCF Calculator
Find the greatest common factor of two or more numbers.
Simple Interest Calculator
Calculate interest earned on a principal without compounding.
Present Value Calculator
Find the current value of a future sum of money.
Basic Calculator
Fast arithmetic: add, subtract, multiply, divide.
Random Number Generator
Generate random integers within any range.