Is it prime? Prime number checker

Is it prime, and its prime factors.

Prime number checker

Is 221 prime?

No

221 = 13 × 17

Number of divisors
4
Previous prime
211
Next prime
223

Runs in your browser. Nothing uploaded.

How to check if a number is prime

  1. Type a whole number of up to 18 digits in Number.
  2. Read the answer. If it isn't prime, its prime factorization is shown underneath, with powers for repeated factors.
  3. Below that are the number of divisors and the closest primes below and above your number.

Quick divisibility checks

These quick tests rule out many numbers by hand:

Divisible by Rule Example
2 Last digit is even 1,358
3 Digits add up to a multiple of 3 471: 4 + 7 + 1 = 12
5 Ends in 0 or 5 2,045
9 Digits add up to a multiple of 9 3,069: 3 + 0 + 6 + 9 = 18
11 Alternating sum of digits is a multiple of 11 918,082: 9 − 1 + 8 − 0 + 8 − 2 = 22

2 is the only even prime, and every prime above 3 is one more or one less than a multiple of 6. That doesn’t make every such number prime (25 and 35 aren’t), but it means any prime candidate other than 2 and 3 has to pass that test first.

How the checker works

Small numbers are divided by the first few primes. For anything larger it runs the Miller-Rabin test, which proves primality for every number this size, and splits a composite number with Pollard’s rho method. That is why even an 18-digit number answers at once, where checking every possible divisor would take far too long. The same test finds the previous and next primes by checking the numbers on each side in turn.

Prime factorization is unique: every whole number above 1 breaks down into primes in exactly one way, apart from the order. That’s why factorizations are handy for finding a greatest common factor and least common multiple or for simplifying fractions and square roots.