Skip to content
K Knidox Search…
Math · Number Theory

Prime Number Checker

Check whether a number is prime, see its prime factorization, and find the nearest primes.

A whole number from 2 to 1,000,000,000,000.
Is 97 prime?
Primeprime

97 has no divisors other than 1 and 97.

Nearest prime below
89
Nearest prime above
101
Try a number

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. 97 is prime — nothing between 2 and √97 ≈ 9.8 divides it. 100 is not prime: it splits as 100 = 2² × 5², so it has extra divisors and is called composite.

What makes a number prime

An integer n > 1 is prime when it cannot be written as a product of two smaller whole numbers — its only factors are 1 and n itself. Every other integer above 1 is composite and factors uniquely into primes (the fundamental theorem of arithmetic). To test n, you only need to look for a divisor up to √n: if no whole number from 2 to √n divides n evenly, then n has no factor pair at all and must be prime.

n is prime ⇔ no integer d with 2 ≤ d ≤ √n divides n

any composite n = a × b must have a factor ≤ √n, so checking past √n is unnecessary

Worked example

Check whether 97 is prime:

  1. 1
    Confirm n is a whole number above 1. 0 and 1 are not prime, and primality is only defined for whole numbers. 97 qualifies.
  2. 2
    Find the test bound √n. √97 ≈ 9.85, so you only need to test divisors from 2 up to 9.
  3. 3
    Try each prime up to that bound. 97 is odd (not ÷2), digit sum 16 (not ÷3), does not end in 0 or 5 (not ÷5), and 97 ÷ 7 ≈ 13.86 (not ÷7).
  4. 4
    No divisor means prime. Nothing from 2 to 9 divides 97 evenly, so 97 is prime. By contrast 100 ÷ 2 = 50, so 100 is composite: 100 = 2² × 5².

The first prime numbers

2 is the only even prime; every even number above 2 is divisible by 2, so it cannot be prime.

RangePrimes
1–102, 3, 5, 7
11–2011, 13, 17, 19
21–3023, 29
31–5031, 37, 41, 43, 47
51–10053, 59, 61, 67, 71, 73, 79, 83, 89, 97

Edge cases, 1, and how primes thin out

1 is not prime. A prime must have exactly two distinct divisors; 1 has only one. Excluding 1 is also what keeps prime factorization unique, so it is a definition, not an oversight.

Trial division is exact but slow. Testing divisors up to √n always gives the right answer, and it is quick for the everyday numbers most calculators see. For numbers with hundreds of digits, cryptographic software switches to probabilistic tests like Miller–Rabin instead.

Primes thin out. There are infinitely many primes (Euclid proved it), but they grow sparser as numbers get larger: there are 4 primes below 10, 25 below 100, but only 168 below 1,000. Gaps between consecutive primes tend to widen, which is why finding the nearest prime above a large number can take several steps.

What exactly is a prime number?
A prime is a whole number greater than 1 whose only positive divisors are 1 and itself. 7 is prime because nothing except 1 and 7 divides it, while 6 is composite because 2 and 3 also divide it.
Is 1 a prime number?
No. A prime must have exactly two distinct divisors, but 1 has only one (itself). Excluding 1 also keeps every number’s prime factorization unique, so it is treated as neither prime nor composite.
Is 2 a prime number?
Yes — 2 is prime, and it is the only even prime. Every larger even number is divisible by 2 as well as 1 and itself, so it has more than two divisors and cannot be prime.
How does the checker decide if a number is prime?
It uses trial division: it tests whether any whole number from 2 up to √n divides n evenly. If none does, n is prime; if one does, n is composite and the tool shows the full prime factorization, such as 100 = 2² × 5².
Why only test divisors up to the square root?
If n = a × b is composite, at least one of the factors must be ≤ √n. So if no divisor exists up to √n, none exists at all. For 97 you only check 2 through 9, since √97 ≈ 9.85.
What is the largest known prime number?
As of 2024 it is 2¹³⁶²⁷⁹⁸⁴¹ − 1, a Mersenne prime with over 41 million digits, found by the GIMPS distributed-computing project. Such giants are verified with specialized tests, not plain trial division.