Prime Number Checker

Enter any positive integer to find out whether it is prime. The checker reports the next and previous prime numbers, list the nearest primes, and — for non-prime values — shows the smallest prime factor.

Enter a number

Values up to 10,000,000 are supported.

Enter a number and press Check primality.

What makes a number prime

A prime number is a positive integer greater than 1 that has exactly two distinct positive divisors: 1 and itself. In other words, it cannot be written as a product of two smaller positive integers.

  • 2 is the only even prime — every other even number is divisible by 2.
  • 1 is not prime, because it has only one divisor.
  • 0 and negatives are not prime.
  • The primes less than 30 are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.

The primality test used

The checker uses trial division up to the square root of the number. It first rules out even numbers and multiples of small primes, then tests odd divisors up to ⌊√n⌋. Any factor larger than √n must be paired with a factor smaller than √n, so testing up to √n is sufficient.

n is prime ⟺ no integer d in [2, √n] divides n

Frequently asked questions

No. By definition, a prime number must have exactly two distinct positive divisors. The number 1 has only one divisor (itself), so it is not prime.

Yes. 2 is prime, and it is the only even prime number. Every other even number is divisible by 2 and therefore composite.

Infinitely many. This was proved by Euclid over 2,000 years ago. However, primes become less frequent as numbers grow larger: roughly one in every ln(n) numbers near n is prime.

There is no largest prime — the set of primes is infinite. However, the largest known prime keeps growing as computational power increases. This checker works up to 10 million for practical reasons.