DoubleCheckCalc

All tools

Prime number checker

Is it prime? The answer, with the factor that proves it

Type a whole number. The example is 97.

Up to 9,007,199,254,740,991

–

Nearest prime below
–
Nearest prime above
–

Working, step by step

    What makes a number prime

    A prime number is a whole number bigger than 1 whose only factors are 1 and itself. 2, 3, 5, 7, 11 and 13 are prime. 9 is not, because 9 = 3 × 3. The number 1 is not prime: it has only one factor. 2 is the only even prime, since every other even number divides by 2.

    How the page checks

    It tries to divide your number by 2, by 3, and then by every number of the form 6k − 1 and 6k + 1 (5, 7, 11, 13, 17, 19 and so on), stopping at the square root. If any of them divides exactly, the number is not prime and the page shows that factor as proof, for example 91 = 7 × 13. If none does, the number is prime. Stopping at the square root is safe: if a number had a factor above its square root, the other factor in the pair would be below it and would already have been found.

    How big a number can it check?

    Up to 9,007,199,254,740,991, the largest whole number a browser stores exactly. For the biggest numbers the check makes up to about thirty million divisions, which a phone may take a second or two to do.

    Nearest primes

    The nearest primes below and above your number are found the same way, one number at a time. They are handy for spotting twin primes, such as 11 and 13, which are two apart.

    Formula and sources

    Related tools