Prime Number Checker

Type a whole number to see if it is prime. If it is not, you get its smallest divisor, prime factorization and full list of factors, along with the previous and next prime.

Any whole number from 0 to 18,446,744,073,709,551,615 (2^64 − 1). Commas are fine.

Try:

Is 97 a prime number?

Answer

Yes, prime

97 has exactly two factors: 1 and 97.

Factors
1 and 97
Previous prime
89
Next prime
101
Test used
Trial division
exact, not a guess

How the checker knows

  1. Find the square root. If 97 had a factor pair, the smaller factor would be at most its square root.√97 is between 9 and 10
  2. Try every possible divisor. No whole number from 2 up to 9 divides 97 evenly.
  3. Conclusion. 97 has exactly two factors, 1 and 97, so it is prime.

What is a prime number?

A prime number is a whole number greater than 1 whose only factors are 1 and itself. 7 is prime because nothing but 1 and 7 divides it evenly. 12 is not prime, because 2, 3, 4 and 6 also divide it; a whole number above 1 that is not prime is called composite.

  • 0 and 1 are not prime. They are neither prime nor composite.
  • 2 is the only even prime. Every larger even number is divisible by 2.
  • Every whole number above 1 is prime or a product of primes, in exactly one way apart from order. That product is its prime factorization.

How to check if a number is prime

The method you learn in class is trial division: divide by each prime in turn and see whether any of them goes in evenly. You only need to go up to the square root. If a number had a factor bigger than its square root, the matching factor in the pair would be smaller than the square root, and you would already have found it.

Is 91 prime?

√91 ≈ 9.54, so try 2, 3, 5, 7. 91 ÷ 7 = 13, so 91 is not prime.

Is 89 prime?

√89 ≈ 9.43, so try 2, 3, 5, 7. None divides 89 evenly, so 89 is prime.

Quick rules rule out most numbers before you divide: an even number above 2 is divisible by 2, a number whose digits add up to a multiple of 3 is divisible by 3, and a number ending in 0 or 5 (other than 5) is divisible by 5.

How this prime number checker works

Every calculation runs in your browser with exact whole-number arithmetic, so even 20-digit numbers are never rounded.

  • Below 2^32 (about 4.3 billion), the checker uses trial division, exactly as above, trying every possible divisor up to the square root.
  • From 2^32 up to 2^64 − 1, trying every divisor would take too long, so it uses the Miller-Rabin test. In plain terms, the test picks a base such as 2 and raises it to powers built from the number minus 1, working with remainders. A prime always behaves in a predictable way under this test; most composite numbers break the pattern straight away. Run with a single base the test can be fooled, but mathematicians have checked that no composite number below 2^64 passes it for all twelve bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 and 37. So for this range the answer is proven, not just likely.
  • Above 2^64 − 1 (18,446,744,073,709,551,615), the checker does not give an answer rather than risk a wrong one.
  • Factors come from trial division by small primes and then Pollard's rho method, a fast way to split large numbers. It has a fixed work limit so the page never freezes. If a number is too large to factor within that limit, the checker still tells you it is not prime and says which part it could not split.

Prime factorization

The prime factorization writes a number as a product of primes. Divide by the smallest prime that goes in, then repeat with what is left until you reach 1. For 360:

360 as a product of primes

360 = 23 × 32 × 5

The exponents tell you how many factors a number has: add 1 to each exponent and multiply. For 360 that is 4 × 3 × 2 = 24 factors.

Prime numbers from 1 to 100

There are 25 prime numbers up to 100.

RangePrimesCount
1 to 102, 3, 5, 74
11 to 2011, 13, 17, 194
21 to 3023, 292
31 to 4031, 372
41 to 5041, 43, 473
51 to 6053, 592
61 to 7061, 672
71 to 8071, 73, 793
81 to 9083, 892
91 to 100971

Working with data rather than single numbers? Try the mean, median and mode calculator or the standard deviation calculator. To see where a test score leaves your class grade, use the grade calculator.

Frequently Asked Questions

More math and statistics calculators