Sign up
Prime Number calculator →

Prime Number guide

The Prime Number Calculator determines whether a number is prime, lists all of its factors, and finds the nearest prime numbers above and below it. It uses an optimized trial division algorithm to handle large inputs quickly.

Worked examples

Check if a number is prime

  1. Enter 17 in the input field.
  2. Click Calculate.
Result: 17 is a Prime Number

17 has only two divisors: 1 and 17. The calculator checks all possible factors up to the square root of 17 (≈4.12) and finds none.

Find the factors of a composite number

  1. Enter 24.
  2. Click Calculate.
Result: Factors: 1, 2, 3, 4, 6, 8, 12, 24 | Not Prime

Because 24 has divisors other than 1 and itself, it is a composite number.

Check the special case of 1

  1. Enter 1.
  2. Click Calculate.
Result: 1 is NEITHER Prime nor Composite

By definition, a prime number must have exactly two distinct divisors. The number 1 only has one divisor (itself).

Tips

  • •2 is the only even prime number.
  • •Use the "Prime Cheat Sheet" button to generate a list of all primes up to 1,000.
  • •The largest known primes are Mersenne primes and have millions of digits.

Frequently asked questions

What is a prime number?
A whole number greater than 1 that has exactly two divisors: 1 and itself.
Is 1 a prime number?
No. By definition, a prime must have exactly two distinct positive divisors. The number 1 only has one (itself).
Is 2 a prime number?
Yes. It is the smallest and the only even prime number.
What is a composite number?
A positive integer greater than 1 that has at least one divisor other than 1 and itself (e.g., 4, 6, 9, 10).
What are twin primes?
Two prime numbers that are exactly 2 apart, such as 11 and 13, or 17 and 19.
What is a Mersenne prime?
A prime number that can be written as 2^n - 1 (e.g., 3, 7, 31). They are the largest known primes.
How does the calculator check for primality?
It uses trial division. It divides the number by all integers up to its square root. If none divide evenly, the number is prime.
Why check only up to the square root?
If a number n has a factor greater than its square root, it must also have a corresponding factor smaller than the square root. So checking up to √n is sufficient.
Are there negative prime numbers?
In standard number theory, primes are strictly positive integers greater than 1. This calculator rejects negative inputs.
What is the Fundamental Theorem of Arithmetic?
It states that every integer greater than 1 can be uniquely represented as a product of prime numbers.
Can a prime number be even?
Only the number 2. Every other even number is divisible by 2, making it composite.
Why is 0 not prime?
Zero is divisible by every number, so it has infinite divisors. Prime numbers must have exactly two.
What is the largest known prime number?
As of 2024, the largest known prime is 2^136,279,841 − 1, which has over 41 million digits.
How many prime numbers are there?
There are infinitely many prime numbers. This was proven by Euclid over 2000 years ago.
What is the prime gap?
The difference between two consecutive prime numbers. For example, the gap between 23 and 29 is 6.
What is a prime triplet?
Three primes of the form (p, p+2, p+6) or (p, p+4, p+6), such as (5, 7, 11).
Does the calculator show the nearest primes?
Yes. It identifies the closest prime number below and above your input.
Can I check a very large number?
Yes, but extremely large numbers (over 15 digits) may lose precision or take longer to process in a web browser.