Skip to content
MasterMath

Prime Number Calculator

Check whether a number is prime, and find the primes either side of it. If it is composite, you get its smallest divisor as proof.

Is it prime?

—

Is it prime?—
Its smallest divisor—
Previous prime—
Next prime—
Does it have a twin?—

How this was worked out

    The rule

    prime if it has no divisor between 2 and √n

    Why it works

    A prime has exactly two divisors: one and itself. Testing only up to the square root is enough, because if a number had a divisor larger than its root, the matching partner would be smaller, and you would have found that one already.

    How to do it by hand

    1. Numbers below 2 are not prime
    2. Test divisibility by 2, then by each odd number
    3. Stop at the square root of the number
    4. No divisor found means it is prime

    What is worth knowing

    The square-root cutoff is what makes the test practical: checking 1,000,003 needs only 1000 trials, not a million. Euclid proved there are infinitely many primes around 300 BC, with an argument short enough to fit in a sentence: multiply any finite list together, add one, and the result has a prime factor not on the list. Twin primes — pairs two apart, like 41 and 43 — are conjectured to be infinite too, and that remains open despite substantial progress since 2013. Primes thin out as numbers grow, but they never run out.

    Frequently asked questions

    Why only test up to the square root?

    Because divisors come in pairs. If one were larger than the root, its partner would be smaller, and you would have found it already.

    Is 1 a prime number?

    No. A prime has exactly two distinct divisors, and 1 has only one.

    Are there infinitely many primes?

    Yes, and Euclid proved it. Multiply any finite list of primes and add 1: the result has a prime factor not on the list.

    What is a twin prime?

    A pair of primes two apart, like 11 and 13. Whether there are infinitely many is still an open problem.