Prime Number Checker & Complete FAQ Guide
Instantly test any whole number for primality — then master the definition, key formulas, historical theorems, and every common question answered with real mathematical expressions.
🔢 Prime Number Checker Calculator
Enter any whole number to instantly find out whether it is prime or composite.
What Is a Prime Number? The Complete Definition
A prime number is any natural number \( n \) that is strictly greater than 1 and has exactly two distinct positive divisors — the number 1 and the number \( n \) itself. In formal mathematical notation:
Read aloud: "n is prime if and only if n is greater than 1 and every positive integer d that divides n must equal 1 or n."
The first ten prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. Numbers greater than 1 that fail this test are called composite numbers — they can always be factored into smaller positive integers. For example, \( 12 = 2^2 \times 3 \) is composite, while 13 is prime.
⚡ Quick Reference: Prime vs. Composite vs. Unit
| Category | Rule | Examples |
|---|---|---|
| Prime | Exactly 2 positive divisors: 1 and itself | 2, 3, 5, 7, 11, 13, 97 |
| Composite | More than 2 positive divisors | 4, 6, 9, 15, 91, 100 |
| Unit | Exactly 1 positive divisor (itself) | 1 only |
| Special | Zero divisors / infinite divisors | 0 |
The Fundamental Theorem of Arithmetic
Every integer greater than 1 either is a prime or can be written as a unique product of prime numbers. This result, known as the Fundamental Theorem of Arithmetic, is why primes are often called the "atoms" of mathematics:
This uniqueness is the deep reason why the number 1 is excluded from the prime definition. If 1 were prime, every number would have infinitely many factorizations: \( 6 = 2 \times 3 = 1 \times 2 \times 3 = 1^2 \times 2 \times 3 = \cdots \). Excluding 1 preserves factorization uniqueness — the cornerstone of number theory.
How to Check if a Number is Prime — Step-by-Step
The standard method is trial division. The mathematical key insight: if a composite number \( n \) has a divisor \( d \), then at least one divisor must be at or below \( \sqrt{n} \):
- Eliminate base cases: If \( n \leq 1 \), not prime. If \( n = 2 \), it is prime (stop here). If \( n > 2 \) and \( n \) is even (i.e., \( n \bmod 2 = 0 \)), it is not prime.
- Compute the test limit: Calculate \( \lfloor\sqrt{n}\rfloor \). This is the highest divisor you ever need to test.
- Test odd divisors: Check each odd integer \( i = 3, 5, 7, \ldots \) up to \( \sqrt{n} \). If \( n \bmod i = 0 \) for any \( i \), then \( n \) is composite — stop and report the factor.
- Declare prime: If you complete the loop with no divisor found, \( n \) is prime.
Prime Numbers 1–100 Visual Grid
The 25 prime numbers between 1 and 100 are highlighted in green. Composite numbers appear in pink, and the unit (1) is shown in indigo.
There are exactly 25 primes below 100. The density of primes gradually decreases as numbers grow larger — a pattern described precisely by the Prime Number Theorem.
The Prime Number Theorem
The Prime Number Theorem (PNT) answers the question: "About how many primes are there up to a given number \( x \)?" Let \( \pi(x) \) denote the prime-counting function — the number of primes less than or equal to \( x \). The theorem states:
In plain terms: roughly 1 in every \( \ln(x) \) numbers near \( x \) is prime. At \( x = 1{,}000 \), about \( 1 \) in \( 6.9 \) numbers is prime; at \( x = 1{,}000{,}000 \), about \( 1 \) in \( 13.8 \). The theorem was proved independently by Hadamard and de la Vallée Poussin in 1896, answering one of the deepest questions in 19th-century mathematics.
| Upper limit \(x\) | Actual \(\pi(x)\) | Approx. \(x / \ln x\) | % Error |
|---|---|---|---|
| \(100\) | 25 | 21.7 | 13% |
| \(1{,}000\) | 168 | 144.8 | 13.8% |
| \(10{,}000\) | 1,229 | 1,085.7 | 11.7% |
| \(1{,}000{,}000\) | 78,498 | 72,382.4 | 7.8% |
| \(1{,}000{,}000{,}000\) | 50,847,534 | 48,254,942 | 5.1% |
Special Types of Prime Numbers
Mersenne Primes
A Mersenne prime is a prime of the form \( M_p = 2^p - 1 \) where \( p \) is itself prime. Not every prime \( p \) gives a Mersenne prime, but when it does, the result can be astronomically large. The largest known prime (discovered by GIMPS in 2018) is:
Twin Primes
A twin prime pair consists of two primes that differ by exactly 2. The general form is \( (p,\ p+2) \). Examples include \( (3,5),\ (5,7),\ (11,13),\ (17,19),\ (29,31),\ (41,43),\ (71,73) \). Whether there are infinitely many twin primes remains one of the great unsolved problems in mathematics.
Sophie Germain Primes
A prime \( p \) is a Sophie Germain prime if \( 2p + 1 \) is also prime. The associated prime \( 2p+1 \) is called a safe prime. These primes have important applications in cryptography, particularly in Diffie–Hellman key exchange.
Fermat Primes
A Fermat prime is a prime of the form \( F_n = 2^{2^n} + 1 \). Only five are known: \( F_0=3,\ F_1=5,\ F_2=17,\ F_3=257,\ F_4=65537 \). It is unknown whether any further Fermat primes exist — all higher Fermat numbers tested so far are composite.
Euclid's Proof: Infinitely Many Primes
Around 300 BC, Euclid proved there are infinitely many prime numbers. His elegant proof by contradiction goes as follows:
- Assume finite: Suppose there are only finitely many primes \( p_1, p_2, \ldots, p_k \).
- Construct a new number: Form \( Q = p_1 \cdot p_2 \cdots p_k + 1 \).
- Analyze Q: \( Q \) is either prime or composite. If prime, it is a new prime not in our list — contradiction.
- If composite: \( Q \) must be divisible by some prime \( p_i \) in our list. But \( Q \bmod p_i = 1 \neq 0 \) for every \( p_i \) in the list — contradiction.
- Conclusion: The assumption of finitely many primes is false. There are infinitely many primes. \( \blacksquare \)
Why 1 Is Not a Prime Number
The number 1 has exactly one positive divisor (itself), while a prime requires exactly two. Allowing 1 to be prime would shatter the uniqueness guarantee of the Fundamental Theorem of Arithmetic — every number would have infinitely many "prime" factorizations:
Mathematicians therefore classify 1 as a unit — a separate category that is neither prime nor composite. This is a deliberate, logically necessary convention, not an arbitrary rule.
Why 2 Is the Only Even Prime
Two is the smallest and the only even prime number. Every even number greater than 2 can be written as \( 2k \) for some integer \( k > 1 \), which means it is divisible by 1, 2, \( k \), and \( 2k \) — giving it at least three distinct positive divisors, making it composite by definition.
Is N a Prime? Quick Reference Table (1–127)
The table below answers the most-searched "is ___ a prime number?" questions. Where a number is composite, the smallest non-trivial factor is shown so you can see the factorization immediately.
| Number | Prime? | Reason / Key Factor |
|---|---|---|
| 1 | ✗ No | Unit — only 1 divisor |
| 2 | ✓ Yes | Smallest prime; only even prime |
| 3 | ✓ Yes | Divisors: 1, 3 |
| 4 | ✗ No | \(4 = 2 \times 2\) |
| 5 | ✓ Yes | Divisors: 1, 5 |
| 6 | ✗ No | \(6 = 2 \times 3\) |
| 7 | ✓ Yes | Divisors: 1, 7 |
| 9 | ✗ No | \(9 = 3^2\) |
| 11 | ✓ Yes | Divisors: 1, 11 |
| 13 | ✓ Yes | Divisors: 1, 13 |
| 15 | ✗ No | \(15 = 3 \times 5\) |
| 17 | ✓ Yes | Divisors: 1, 17 |
| 19 | ✓ Yes | Divisors: 1, 19 |
| 21 | ✗ No | \(21 = 3 \times 7\) |
| 23 | ✓ Yes | Divisors: 1, 23 |
| 25 | ✗ No | \(25 = 5^2\) |
| 27 | ✗ No | \(27 = 3^3\) |
| 29 | ✓ Yes | Divisors: 1, 29 |
| 31 | ✓ Yes | Divisors: 1, 31 |
| 33 | ✗ No | \(33 = 3 \times 11\) |
| 35 | ✗ No | \(35 = 5 \times 7\) |
| 37 | ✓ Yes | Divisors: 1, 37 |
| 39 | ✗ No | \(39 = 3 \times 13\) |
| 41 | ✓ Yes | Divisors: 1, 41 |
| 43 | ✓ Yes | Divisors: 1, 43 |
| 47 | ✓ Yes | Divisors: 1, 47 |
| 49 | ✗ No | \(49 = 7^2\) |
| 51 | ✗ No | \(51 = 3 \times 17\) |
| 53 | ✓ Yes | Divisors: 1, 53 |
| 57 | ✗ No | \(57 = 3 \times 19\) |
| 59 | ✓ Yes | Divisors: 1, 59 |
| 61 | ✓ Yes | Divisors: 1, 61 |
| 63 | ✗ No | \(63 = 7 \times 9 = 3^2 \times 7\) |
| 67 | ✓ Yes | Divisors: 1, 67 |
| 69 | ✗ No | \(69 = 3 \times 23\) |
| 71 | ✓ Yes | Divisors: 1, 71 |
| 73 | ✓ Yes | Divisors: 1, 73 |
| 79 | ✓ Yes | Divisors: 1, 79 |
| 81 | ✗ No | \(81 = 3^4\) |
| 83 | ✓ Yes | Divisors: 1, 83 |
| 87 | ✗ No | \(87 = 3 \times 29\) |
| 89 | ✓ Yes | Divisors: 1, 89 |
| 91 | ✗ No | \(91 = 7 \times 13\) — commonly mistaken for prime! |
| 93 | ✗ No | \(93 = 3 \times 31\) |
| 97 | ✓ Yes | Largest prime below 100 |
| 101 | ✓ Yes | Divisors: 1, 101 |
| 111 | ✗ No | \(111 = 3 \times 37\) (digit sum = 3) |
| 113 | ✓ Yes | Divisors: 1, 113 |
| 117 | ✗ No | \(117 = 9 \times 13\) |
| 119 | ✗ No | \(119 = 7 \times 17\) |
| 121 | ✗ No | \(121 = 11^2\) |
| 127 | ✓ Yes | Mersenne prime: \(2^7 - 1\) |
Divisibility Rules That Speed Up Prime Testing
Before running full trial division, apply these quick divisibility rules to instantly rule out composites. A number passes ALL of the applicable rules below only if none of the small primes divide it.
| Divisible by | Rule | Example |
|---|---|---|
| 2 | Last digit is 0, 2, 4, 6, or 8 | 348 → ends in 8 → divisible by 2 |
| 3 | Sum of all digits is divisible by 3 | 111 → 1+1+1=3 → divisible by 3 |
| 5 | Last digit is 0 or 5 | 325 → ends in 5 → divisible by 5 |
| 7 | Double last digit, subtract from rest; repeat | 91 → 9 − 2×1 = 7 → divisible by 7 |
| 11 | Alternating digit sum (odd positions − even positions) divisible by 11 | 121 → 1−2+1=0 → divisible by 11 |
| 13 | Add 4× last digit to rest; repeat | 91 → 9+4×1=13 → divisible by 13 |
\[ 3 \mid n \iff 3 \mid \left(\sum_{i} d_i\right) \quad \text{where } d_i \text{ are the decimal digits of } n \] Divisibility by 11:
\[ 11 \mid n \iff 11 \mid \left(\sum_{i\,\text{odd}} d_i - \sum_{i\,\text{even}} d_i\right) \]
The Sieve of Eratosthenes
When you need to find all primes up to a limit \( N \), the Sieve of Eratosthenes (invented around 240 BC) is far more efficient than testing each number individually. The algorithm eliminates all multiples of each prime discovered, leaving only primes behind.
- Write all integers from 2 to \( N \). Mark them all as potentially prime.
- Start at \( p = 2 \) (the first prime). Mark all multiples of \( p \) (i.e., \( 2p, 3p, 4p, \ldots \)) as composite. Do not mark \( p \) itself.
- Move to the next unmarked number. That number is the next prime. Repeat step 2 for this new prime.
- Stop when \( p > \sqrt{N} \). All remaining unmarked numbers are prime.
Frequently Asked Questions About Prime Numbers
What exactly makes a number prime?
A number \( n \) is prime when it satisfies three conditions simultaneously: (1) it is a natural number, (2) it is strictly greater than 1, and (3) it has no positive divisors other than 1 and \( n \) itself. Formally:
The condition \( 1 < d < n \) checks for non-trivial divisors. If none exist, \( n \) is prime. If even one exists, \( n \) is composite.
Is 0 a prime number?
No. Zero fails both major criteria for primality. First, it is not greater than 1. Second, zero is divisible by every non-zero integer — it has infinitely many positive divisors. A prime must have exactly two. Zero is neither prime nor composite; it is simply zero.
Is 2 a prime number? Why is it special?
Yes, 2 is prime. It is both the smallest prime and the only even prime. Its divisors are exclusively 1 and 2. Every even number \( n > 2 \) satisfies \( 2 \mid n \), giving it at least three divisors (1, 2, and \( n \)), which disqualifies it from being prime.
What is the square root rule for prime testing?
If a composite number \( n \) has a factor \( a \), then the complementary factor \( b = n/a \) satisfies \( b \leq \sqrt{n} \) whenever \( a \geq \sqrt{n} \). Therefore, you never need to test divisors beyond \( \lfloor\sqrt{n}\rfloor \):
Why is 91 commonly mistaken for a prime?
91 looks prime because it is odd, not divisible by 3 (digit sum = 10), not ending in 0 or 5, and its square root is about 9.5 — so you'd need to test 7 specifically. Many people stop their mental check too early and miss that \( 7 \times 13 = 91 \). It is one of the most well-known "prime imposters."
Are there infinitely many prime numbers?
Yes. Euclid proved this around 300 BC with a clean proof by contradiction (see the detailed proof section above). No matter how large a prime you find, there are always infinitely more primes ahead of it. The prime-counting function \( \pi(x) \to \infty \) as \( x \to \infty \).
What is the largest known prime number?
As of the most recent confirmed discovery, the largest known prime is the Mersenne prime \( 2^{82{,}589{,}933} - 1 \), found in December 2018 by the Great Internet Mersenne Prime Search (GIMPS). It contains over 24.8 million digits. Searches for larger primes are ongoing.
What is a prime factorization and how do you find it?
Prime factorization expresses any composite number as a product of primes. Divide the number by its smallest prime factor, then repeat on the quotient until you reach 1. The collected prime factors form the unique factorization guaranteed by the Fundamental Theorem of Arithmetic.
How are prime numbers used in cryptography?
Modern public-key cryptography — including RSA encryption used by your browser right now — relies on the fact that multiplying two large primes is computationally trivial, but factoring their product back into the two primes is computationally infeasible for very large numbers.
Factoring a 2048-bit RSA modulus \( n \) would take modern supercomputers longer than the estimated age of the universe — which is why prime numbers are the foundation of internet security.
What is Goldbach's Conjecture?
Goldbach's Conjecture (1742) is one of the oldest unsolved problems in mathematics. It states that every even integer greater than 2 can be expressed as the sum of two prime numbers. It has been verified for all even numbers up to \( 4 \times 10^{18} \) but has never been formally proved.
What is the Riemann Hypothesis and its connection to primes?
The Riemann Hypothesis (1859) is the most famous unsolved problem in mathematics, with a $1 million Millennium Prize from the Clay Mathematics Institute. It concerns the zeros of the Riemann zeta function and, if proved true, would provide the most precise known bounds on the distribution of prime numbers.
What is Wilson's Theorem for identifying primes?
Wilson's Theorem gives a mathematically exact (though computationally expensive) test for primality using factorials and modular arithmetic:
Example: \( p = 4 \): \( (4-1)! = 6 \equiv 2 \pmod{4} \neq -1 \) ✗ not prime.
While Wilson's Theorem is theoretically elegant, computing \( (p-1)! \) is far too slow for large numbers, so it is not used in practice. The Sieve of Eratosthenes and Miller-Rabin tests are preferred instead.
📚 Keep Exploring Mathematics at He Loves Math
Discover hundreds of in-depth math guides, calculators, and visual tools — all free, all human-first.
Explore All Math Topics →


