Math & Number Theory

Prime Number Checker

Is your number prime? Find prime factorization, list all primes in a range, find the Nth prime, discover twin primes, and visualize the Sieve of Eratosthenes — with full step-by-step working.

7 Calculation Modes
Step-by-Step Working
Up to 10 Million
100% Free

Prime Number Checker — All Modes

Select a tool, enter your number(s), and get instant results with complete step-by-step working

🔍
Check Prime
Is N prime?
🌿
Factorize
Prime factors
📋
List Primes
Primes in range
🏆
Nth Prime
Find the Nth one
👥
Twin Primes
Pairs differ by 2
📏
Prime Gap
Next & prev prime
🧮
Sieve Visual
Eratosthenes
🔍 Check Prime: Is N a prime number?
to
to
Purple = prime
Grey = composite
🔍 RESULT
Answer ready
Result Summary
More Useful Results
Visual Breakdown
Step-by-Step Working
    Share This Result

    What Are Prime Numbers?

    Core concepts, history, and why primes are the fundamental building blocks of all mathematics

    The Atoms of Arithmetic

    A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23… The number 2 is the only even prime — every other even number is divisible by 2 and therefore composite.

    The Fundamental Theorem of Arithmetic states that every integer greater than 1 can be expressed as a unique product of prime numbers (up to the order of factors). This makes primes the irreducible "atoms" from which all whole numbers are built. For example, 360 = 2³ × 3² × 5 — there is no other way to write 360 as a product of primes.

    Are there infinitely many primes? Yes — Euclid proved this around 300 BC with an elegant argument. Assume there are finitely many primes p₁, p₂, …, pₙ. Multiply them all and add 1: N = (p₁ × p₂ × … × pₙ) + 1. N is either prime itself (a new prime!) or divisible by a prime not in the list — a contradiction. Therefore the list can never be complete.
    🔑
    Cryptography

    RSA encryption — which secures every HTTPS website — relies on the fact that multiplying two large primes is easy, but factoring the result back is computationally infeasible.

    👥
    Twin Primes

    Twin primes are pairs of primes that differ by 2, like (3,5), (11,13), (17,19). Whether there are infinitely many twin primes is one of mathematics' greatest unsolved problems.

    🧮
    Sieve of Eratosthenes

    A 2,000-year-old algorithm: write all numbers, strike out multiples of 2, then multiples of 3, 5, 7… What remains are all the primes. Still one of the most efficient methods for small ranges.

    🏆
    Largest Known Prime

    As of 2024, the largest known prime is 2¹³⁶²⁷⁹⁸⁴¹ − 1, a Mersenne prime with over 41 million digits, discovered by the GIMPS project in October 2024.

    Primality Test Methods — Reference

    How to check if a number is prime, from basic trial division to advanced tests

    MethodHow It WorksBest ForComplexity
    Trial DivisionCheck divisibility by all primes up to √NN < 10⁶O(√N)
    Sieve of EratosthenesStrike out all multiples; remainders are primeFind all primes up to NO(N log log N)
    Miller-RabinProbabilistic test using modular exponentiationVery large numbersO(k log²N)
    AKS Primality TestDeterministic polynomial-time algorithmTheoretical / academicO(log⁶N)
    Fermat TestIf N is prime: aᴺ⁻¹ ≡ 1 (mod N)Quick pre-checkO(log N)
    Trial Division shortcut: You only need to test divisors up to √N. If N has no prime factor ≤ √N, then N is prime. For example, to check 97: √97 ≈ 9.8. Test 2, 3, 5, 7 — none divide 97 evenly. So 97 is prime. That's only 4 checks instead of 96!

    Frequently Asked Questions

    Common questions about prime numbers and primality testing

    Is 1 a prime number?
    No. By definition, a prime must have exactly two distinct positive divisors: 1 and itself. The number 1 has only one positive divisor (itself), so it fails this criterion. Historically, mathematicians did sometimes consider 1 prime, but the modern definition excludes it to preserve the uniqueness stated in the Fundamental Theorem of Arithmetic — if 1 were prime, every number would have infinitely many factorisations (e.g., 6 = 2×3 = 1×2×3 = 1×1×2×3 …).
    Why is 2 the only even prime?
    Every even number is divisible by 2. So any even number greater than 2 has at least three divisors: 1, 2, and itself — making it composite. The number 2 is even but only has two divisors (1 and 2), so it qualifies as prime. It's the "oddest" prime in the most literal sense.
    What is prime factorization and why is it useful?
    Prime factorization expresses a number as a product of prime numbers. For example: 360 = 2³ × 3² × 5. It's useful for: finding GCD and LCM of numbers (essential for fractions and ratios), simplifying square roots (√360 = 6√10), understanding divisibility, and underpins RSA encryption which secures internet communications.
    What are twin primes?
    Twin primes are pairs of primes that differ by exactly 2, such as (3,5), (11,13), (17,19), (29,31), (41,43). They become increasingly rare as numbers get larger, but mathematicians believe there are infinitely many — this is the "Twin Prime Conjecture", one of the most famous unsolved problems in mathematics. As of 2024, the largest known twin prime pair has over 388,000 digits.
    What is a prime gap?
    A prime gap is the difference between two consecutive primes. The gap after 2 is 1 (2→3). After that, all gaps are even (since all primes >2 are odd). Gaps can be arbitrarily large — for any N, you can find N consecutive composite numbers using (N+1)! + 2, (N+1)! + 3, …, (N+1)! + (N+1). However, by Bertrand's postulate, there is always at least one prime between N and 2N for N > 1.
    How does the Sieve of Eratosthenes work?
    Start with all numbers 2 to N. Mark 2 as prime, then cross out all multiples of 2. Find the next unmarked number (3) — it's prime. Cross out all multiples of 3. Repeat for the next unmarked number. You only need to sieve up to √N, because any composite number ≤ N must have a prime factor ≤ √N. Everything remaining unmarked after sieving up to √N is prime.
    Is this calculator private? Is data stored?
    Yes, completely private. All calculations run entirely in your browser using JavaScript — no number you enter is ever sent to a server or stored anywhere. The page works fully offline once loaded.