🔢 Prime Number Checker
Enter any number to instantly check if it's prime - with a step-by-step divisibility test and prime factorization. Generate a list of all primes in any range using the Sieve of Eratosthenes, or explore the prime distribution visualisation. Includes twin primes, Mersenne primes, and how prime numbers secure the internet.
Is it Prime?
Try:Sieve of Eratosthenes (1–200)
Blue = Prime Grey = Composite. Click any number to check it.
There are 46 prime numbers between 1 and 200.
Find Primes in a Range
Prime Number Facts
Prime Number Formulas & Theory
Definition of a Prime Number
exactly TWO factors: 1 and itself.
Prime: 2, 3, 5, 7, 11, 13, 17, 19, 23...
Composite: 4=2×2, 6=2×3, 8=2×2×2, 9=3×3...
Special: 1 is NEITHER prime nor composite
Trial Division Algorithm
To check if n is prime, only test divisors up to √n.
if n < 2: return False
if n == 2: return True
if n % 2 == 0: return False
for i from 3 to √n (step 2):
if n % i == 0: return False
return True
Why √n? If n = a×b and a ≤ b,
then a ≤ √n - so we only need to check up to √n.
Prime Factorization
Every composite number can be uniquely expressed as a product of primes (Fundamental Theorem of Arithmetic).
Example: 360
360 ÷ 2 = 180
180 ÷ 2 = 90
90 ÷ 2 = 45
45 ÷ 3 = 15
15 ÷ 3 = 5
5 ÷ 5 = 1
360 = 2³ × 3² × 5
Mersenne Primes
(where n must itself be prime)
M₂ = 3, M₃ = 7, M₅ = 31, M₇ = 127
M₁₃ = 8191, M₁₇ = 131071
Not all 2ⁿ−1 are prime: M₄ = 15 = 3×5 (composite)
Only 51 Mersenne primes known as of 2024.
Prime Counting Function π(x)
π(10) = 4 (primes: 2,3,5,7)
π(100) = 25
π(1000) = 168
π(10⁶) = 78,498
π(10⁹) = 50,847,534
Prime Number Theorem: π(x) ≈ x / ln(x)
Frequently Asked Questions
Prime Number Checker - How Primality Testing Works and Why Primes Matter
Prime numbers are the atoms of arithmetic - the irreducible building blocks from which all other integers are constructed. Every composite number is just a unique product of primes. This fundamental fact, called the Fundamental Theorem of Arithmetic, underlies everything from elementary factoring to modern cryptography. Understanding how to identify primes - and why the problem gets dramatically harder for large numbers - is one of the most fascinating areas of mathematics.
Different Types of Special Primes
Twin Primes and Prime Pairs
- Twin primes: Pairs differing by 2. (3,5), (11,13), (17,19), (29,31), (41,43), (71,73)
- Twin Prime Conjecture: There are infinitely many twin prime pairs - still unproven, one of mathematics' great open questions
- Cousin primes: Differ by 4: (3,7), (7,11), (13,17)
- Sexy primes: Differ by 6: (5,11), (7,13), (11,17)
- All prime pairs above (3,5) are of the form (6k−1, 6k+1)
Special Prime Forms
- Mersenne primes (2ⁿ−1): 3, 7, 31, 127, 8191... Largest known primes are always Mersenne primes. Found by GIMPS distributed computing project.
- Fermat primes (2^(2ⁿ)+1): 3, 5, 17, 257, 65537. Only 5 known - no new ones found since Euler.
- Palindromic primes: Same forwards and backwards: 11, 101, 131, 151, 181.
- Safe primes (2p+1): Used in cryptographic key generation.
The Sieve of Eratosthenes - The Ancient Algorithm That Still Works
The Sieve of Eratosthenes, invented by the Greek mathematician Eratosthenes around 240 BCE, is one of the oldest known algorithms - and it remains one of the most efficient ways to find all primes up to a given limit. The method:
- List all integers from 2 to n
- Starting at 2 (the first prime), mark all multiples of 2 as composite: 4, 6, 8, 10...
- Move to the next unmarked number (3 - it's prime), mark all its multiples: 6, 9, 12, 15...
- Move to the next unmarked number (5), mark its multiples: 10, 15, 20, 25...
- Repeat until you've processed all numbers up to √n
- All remaining unmarked numbers are prime
Why stop at √n? Because any composite number ≤ n must have a prime factor ≤ √n. So after processing all primes up to √n, all remaining unmarked numbers must be prime. The Sieve tab above implements this for any range you choose.
Prime Numbers and Internet Security - How RSA Encryption Works
The security of most internet communication - HTTPS, banking, email encryption, digital signatures - relies directly on a property of prime numbers: multiplying two large primes is trivially fast, but factoring the product back into those two primes is computationally infeasible.
In RSA encryption: choose two large primes p and q (each with hundreds of digits). Compute n = p × q. The public key includes n; the private key uses p and q separately. Encrypting data uses n (easy - just multiplication). Decrypting requires knowing p and q - and no known algorithm can factor a 2,048-bit number in any reasonable time on current hardware.
The asymmetry between multiplication (fast) and factoring (slow) is the mathematical trapdoor that secures modern cryptography. Every time you see "https://" in a browser, prime numbers are protecting your data.
Famous Unsolved Problems in Prime Number Theory
- Goldbach's Conjecture (1742): Every even integer greater than 2 is the sum of two primes. Verified for all even numbers up to 4 × 10¹⁸, but never proven universally.
- Twin Prime Conjecture: There are infinitely many pairs of primes that differ by 2. Partially proven by Yitang Zhang in 2013, who showed infinitely many pairs with gap ≤ 70,000,000 (later reduced to 246).
- Riemann Hypothesis (1859): All non-trivial zeros of the Riemann zeta function lie on the critical line Re(s) = 1/2. Directly connected to the distribution of primes. One of the Millennium Prize Problems with a $1 million reward.
- Are there infinitely many Mersenne primes? Unknown. Only 51 are known as of 2025.
How this calculator works, and where the numbers come from
The Prime Number Checker applies the standard formula for this calculation to the values you enter and updates the result as you type. The calculation itself happens in your browser, and the page explains the method so you can check any result by hand.
Please note: Results are provided for general information and are calculated from the values you enter.