Prime Number Calculator

Check whether a number is prime, and find the next and previous prime numbers around it.

What Is a Prime Number?: A prime is a whole number greater than 1 that has exactly two divisors: 1 and itself. A number with more divisors is called composite.

How the Check Works: To test a number n, divide it by every prime up to sqrt(n). If none of them divides n exactly, n is prime, because any factor larger than sqrt(n) would need a partner smaller than sqrt(n).

Example:

Number = 29

29 is not divisible by 2, 3 or 5 (the primes up to sqrt(29), about 5.4), so 29 is prime.

Next prime after 29 = 31

Previous prime before 29 = 23

The first primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37...

Frequently Asked Questions

Is 1 a prime number?

No. By definition a prime must have exactly two divisors, but 1 has only one: itself. So 1 is neither prime nor composite; it is its own special case.

Is 2 a prime number?

Yes, and it is the only even prime. Every other even number is divisible by 2, so it cannot be prime.