Prime Number Checker

Find out whether a number is prime, see its prime factorization and divisors, and get the nearest primes on either side.

Enter a whole number

Whole numbers up to 18 digits. Commas are fine. The answer updates as you type.

Try an example

How to use the prime number checker

  1. Type a whole number into Number to check. The page opens with 97. Commas such as 1,000,003 are accepted.
  2. Read the verdict at the top of the result box. It updates as you type, or press Check number to refresh it at once.
  3. For a composite number, read Prime factorization, Number of divisors and Divisors. Every result also lists the Previous prime and Next prime.
  4. Tap an example under Try an example, such as 91 (7 × 13), to see a number that looks prime but is not.

How the checker decides

A prime is a whole number greater than 1 whose only positive divisors are 1 and itself (MathWorld). This tool tests primality with the Miller-Rabin test using the first twelve primes, 2 through 37, as bases. That set is proven exact, not just probable, for every number below 3.18 × 1023 (Sorenson and Webster), so every 18-digit answer is certain. Composites are split by trial division and Pollard's rho method. Every whole number above 1 has exactly one prime factorization (Fundamental Theorem of Arithmetic), and the divisor count is the product of each exponent plus one.

Worked example with the default number

With 97 in Number to check, the tool shows 97 is a prime number.

  • By hand, √97 ≈ 9.85, so you only test the primes 2, 3, 5 and 7: 97 ÷ 2 = 48.5, 97 ÷ 3 ≈ 32.33, 97 ÷ 5 = 19.4 and 97 ÷ 7 ≈ 13.86. None divides evenly.
  • Divisors: 1, 97 (2 divisors). Previous prime: 89. Next prime: 101.

Now type 60. The result reads 60 is not a prime number (composite), with the prime factorization 22 × 3 × 5, 12 divisors (1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60), previous prime 59 and next prime 61. The 12 comes from (2 + 1) × (1 + 1) × (1 + 1).

Limits and edge cases

Related tools: simplify fractions with the fraction calculator, count arrangements with the permutation and combination calculator, or see how fast numbers grow with the factorial calculator.

Frequently asked questions

Is 1 a prime number?

No. A prime needs exactly two different divisors, and 1 has only one. Counting 1 as prime would also break unique prime factorization, because 6 could be written as 2 × 3, 1 × 2 × 3, and so on without end.

Is 0 a prime number?

No. Zero is neither prime nor composite. Every whole number divides 0 evenly, so it has infinitely many divisors rather than exactly two.

Is 51 a prime number?

No. 51 = 3 × 17. Its digits add up to 6, which is divisible by 3, so 3 divides 51. Numbers such as 57 (3 × 19) and 87 (3 × 29) fool people the same way.

How do you find the prime factorization of a number?

Divide by the smallest prime that goes in evenly (2, then 3, 5, 7 and so on) and repeat with the quotient until you reach 1. For 60: 60 ÷ 2 = 30, 30 ÷ 2 = 15, 15 ÷ 3 = 5, and 5 is prime, so 60 = 2² × 3 × 5.

Why is 2 the only even prime number?

Every even number greater than 2 is divisible by 2, so it has at least three divisors: 1, 2 and itself.

Sources: Wolfram MathWorld, Prime Number; Sorenson and Webster, Strong Pseudoprimes to Twelve Prime Bases; OEIS A000040.